r17728 by jghali - refactoring of itemSelection_ClearItem() to make code more readable
scribus-commit
scribus-commit at lists.scribus.net
Sat Jul 21 10:31:24 UTC 2012
Author: jghali
Date: Sat Jul 21 10:31:23 2012
New Revision: 17728
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17728
Log:
refactoring of itemSelection_ClearItem() to make code more readable
Modified:
branches/Version14x/Scribus/scribus/scribusdoc.cpp
Modified: branches/Version14x/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17728&path=/branches/Version14x/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/scribusdoc.cpp (original)
+++ branches/Version14x/Scribus/scribus/scribusdoc.cpp Sat Jul 21 10:31:23 2012
@@ -7611,52 +7611,51 @@
{
Selection* itemSelection = (customSelection!=0) ? customSelection : m_Selection;
assert(itemSelection!=0);
- uint selectedItemCount=itemSelection->count();
- if (selectedItemCount != 0)
- {
- PageItem *currItem;
- bool userDecide = false;
- bool userWantClear = true;
- UndoTransaction* activeTransaction = NULL;
- if (selectedItemCount > 1)
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ClearContent, tr( "Remove content from frames" ), Um::IDelete));
- for (uint i = 0; i < selectedItemCount; ++i)
- {
- currItem = itemSelection->itemAt(i);
- if (currItem->asImageFrame())
- {
- if ((ScCore->fileWatcher->files().contains(currItem->Pfile) != 0) && (currItem->PictureIsAvailable))
- ScCore->fileWatcher->removeFile(currItem->Pfile);
+
+ uint selectedItemCount = itemSelection->count();
+ if (selectedItemCount <= 0) return;
+
+ PageItem *currItem;
+ bool userDecide = false;
+ bool userWantClear = true;
+ UndoTransaction* activeTransaction = NULL;
+ if (selectedItemCount > 1)
+ activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ClearContent, tr( "Remove content from frames" ), Um::IDelete));
+ for (uint i = 0; i < selectedItemCount; ++i)
+ {
+ currItem = itemSelection->itemAt(i);
+ if (currItem->asImageFrame())
+ {
+ if ((ScCore->fileWatcher->files().contains(currItem->Pfile) != 0) && (currItem->PictureIsAvailable))
+ ScCore->fileWatcher->removeFile(currItem->Pfile);
+ currItem->clearContents();
+ }
+ else if (currItem->asTextFrame())
+ {
+ if (ScCore->usingGUI() && (! userDecide))
+ {
+ if (currItem->itemText.length() != 0 && (currItem->nextInChain() == 0 || currItem->prevInChain() == 0))
+ {
+ int t = ScMessageBox::warning(m_ScMW, CommonStrings::trWarning,
+ tr("Do you really want to clear all your text?"),
+ QMessageBox::Yes, QMessageBox::No | QMessageBox::Default);
+ userWantClear = (t != QMessageBox::No);
+ userDecide = true;
+ }
+ }
+ if (userWantClear)
currItem->clearContents();
- }
- else
- if (currItem->asTextFrame())
- {
- if (ScCore->usingGUI() && (! userDecide))
- {
- if (currItem->itemText.length() != 0 && (currItem->nextInChain() == 0 || currItem->prevInChain() == 0))
- {
- int t = ScMessageBox::warning(m_ScMW, CommonStrings::trWarning,
- tr("Do you really want to clear all your text?"),
- QMessageBox::Yes, QMessageBox::No | QMessageBox::Default);
- userWantClear = (t != QMessageBox::No);
- userDecide = true;
- }
- }
- if (userWantClear)
- currItem->clearContents();
- }
- }
- if (activeTransaction)
- {
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
- }
- updateFrameItems();
- regionsChanged()->update(QRectF());
- changed();
- }
+ }
+ }
+ if (activeTransaction)
+ {
+ activeTransaction->commit();
+ delete activeTransaction;
+ activeTransaction = NULL;
+ }
+ updateFrameItems();
+ regionsChanged()->update(QRectF());
+ changed();
}
More information about the scribus-commit
mailing list