diff options
author | jghali <jghali@11d20701-8431-0410-a711-e3c959e3b870> | 2012-07-21 10:31:23 +0000 |
---|---|---|
committer | jghali <jghali@11d20701-8431-0410-a711-e3c959e3b870> | 2012-07-21 10:31:23 +0000 |
commit | d22aa7e856fdc65b1b98691de2e552ec584c67c6 (patch) | |
tree | 610613e760c71a6d72fca4271b98f30b56cf8403 | |
parent | 617663990119e1cf5c1f8eae308453e81a2e9c7d (diff) | |
download | scribus-d22aa7e856fdc65b1b98691de2e552ec584c67c6.tar.gz scribus-d22aa7e856fdc65b1b98691de2e552ec584c67c6.tar.xz scribus-d22aa7e856fdc65b1b98691de2e552ec584c67c6.zip |
refactoring of itemSelection_ClearItem() to make code more readable
git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17728 11d20701-8431-0410-a711-e3c959e3b870
-rw-r--r-- | scribus/scribusdoc.cpp | 75 |
1 files changed, 37 insertions, 38 deletions
diff --git a/scribus/scribusdoc.cpp b/scribus/scribusdoc.cpp index 0bc04b6..72e0dd5 100644 --- a/scribus/scribusdoc.cpp +++ b/scribus/scribusdoc.cpp @@ -7611,52 +7611,51 @@ void ScribusDoc::itemSelection_ClearItem(Selection* customSelection) { Selection* itemSelection = (customSelection!=0) ? customSelection : m_Selection; assert(itemSelection!=0); - uint selectedItemCount=itemSelection->count(); - if (selectedItemCount != 0) + + 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) { - 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()) { - 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->fileWatcher->files().contains(currItem->Pfile) != 0) && (currItem->PictureIsAvailable)) + ScCore->fileWatcher->removeFile(currItem->Pfile); + currItem->clearContents(); + } + else if (currItem->asTextFrame()) + { + if (ScCore->usingGUI() && (! userDecide)) { - if (ScCore->usingGUI() && (! userDecide)) + if (currItem->itemText.length() != 0 && (currItem->nextInChain() == 0 || currItem->prevInChain() == 0)) { - 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; - } + 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 (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(); } |