r19662 by jghali - remove unnecessary long "if" block
scribus-commit
scribus-commit at lists.scribus.net
Sat Dec 13 20:50:40 UTC 2014
Author: jghali
Date: Sat Dec 13 20:50:40 2014
New Revision: 19662
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19662
Log:
remove unnecessary long "if" block
Modified:
branches/Version14x/Scribus/scribus/scribusdoc.cpp
Modified: branches/Version14x/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19662&path=/branches/Version14x/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/scribusdoc.cpp (original)
+++ branches/Version14x/Scribus/scribus/scribusdoc.cpp Sat Dec 13 20:50:40 2014
@@ -10701,82 +10701,82 @@
void ScribusDoc::itemSelection_UnGroupObjects(Selection* customSelection)
{
Selection* itemSelection = (customSelection!=0) ? customSelection : m_Selection;
- if (itemSelection->count() != 0)
- {
- uint docSelectionCount = itemSelection->count();
- PageItem *currItem;
- QMap<PageItem*, int> toDelete;
- QMap<int, QList<PageItem*> > groupObjects;
+ if (itemSelection->count() == 0)
+ return;
+
+ uint docSelectionCount = itemSelection->count();
+ PageItem *currItem;
+ QMap<PageItem*, int> toDelete;
+ QMap<int, QList<PageItem*> > groupObjects;
+ for (uint a=0; a < docSelectionCount; ++a)
+ {
+ currItem = itemSelection->itemAt(a);
+ if (currItem->Groups.count() != 0)
+ {
+ int groupId = currItem->Groups.pop();
+ if (currItem->isGroupControl && (currItem->Groups.count() == 0))
+ toDelete.insert(currItem, groupId);
+ if (!currItem->isGroupControl)
+ groupObjects[groupId].append(currItem);
+ }
+ }
+ // Remove group control objects
+ itemSelection->delaySignalsOn();
+ QMap<PageItem*, int>::iterator it;
+ for (it = toDelete.begin(); it != toDelete.end(); ++it)
+ {
+ itemSelection->removeItem(it.key());
+ Items->removeOne(it.key());
+ }
+ itemSelection->delaySignalsOff();
+ renumberItemsInListOrder();
+ // Create undo actions
+ UndoTransaction* undoTransaction = NULL;
+ if (UndoManager::undoEnabled() && toDelete.count() > 1)
+ {
+ undoTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Ungroup, "", Um::IGroup));
+ }
+ QMap<int, QList<PageItem*> >::iterator groupIt;
+ for (it = toDelete.begin(); it != toDelete.end(); ++it)
+ {
+ //PageItem* groupItem = it.key();
+ //int groupId = it.value();
+ groupIt = groupObjects.find(it.value());
+ if (groupIt == groupObjects.end())
+ continue;
+ QList<PageItem*> groupItems = groupIt.value();
+
+ docSelectionCount = groupItems.count();
+ SimpleState *ss = new SimpleState(Um::Ungroup);
+ ss->set("UNGROUP", "ungroup");
+ ss->set("itemcount", docSelectionCount);
+ QString tooltip = Um::ItemsInvolved + "\n";
+ if (docSelectionCount > Um::ItemsInvolvedLimit)
+ tooltip = Um::ItemsInvolved2 + "\n";
for (uint a=0; a < docSelectionCount; ++a)
{
- currItem = itemSelection->itemAt(a);
- if (currItem->Groups.count() != 0)
- {
- int groupId = currItem->Groups.pop();
- if (currItem->isGroupControl && (currItem->Groups.count() == 0))
- toDelete.insert(currItem, groupId);
- if (!currItem->isGroupControl)
- groupObjects[groupId].append(currItem);
- }
- }
- // Remove group control objects
- itemSelection->delaySignalsOn();
- QMap<PageItem*, int>::iterator it;
- for (it = toDelete.begin(); it != toDelete.end(); ++it)
- {
- itemSelection->removeItem(it.key());
- Items->removeOne(it.key());
- }
- itemSelection->delaySignalsOff();
- renumberItemsInListOrder();
- // Create undo actions
- UndoTransaction* undoTransaction = NULL;
- if (UndoManager::undoEnabled() && toDelete.count() > 1)
- {
- undoTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Ungroup, "", Um::IGroup));
- }
- QMap<int, QList<PageItem*> >::iterator groupIt;
- for (it = toDelete.begin(); it != toDelete.end(); ++it)
- {
- //PageItem* groupItem = it.key();
- //int groupId = it.value();
- groupIt = groupObjects.find(it.value());
- if (groupIt == groupObjects.end())
- continue;
- QList<PageItem*> groupItems = groupIt.value();
-
- docSelectionCount = groupItems.count();
- SimpleState *ss = new SimpleState(Um::Ungroup);
- ss->set("UNGROUP", "ungroup");
- ss->set("itemcount", docSelectionCount);
- QString tooltip = Um::ItemsInvolved + "\n";
- if (docSelectionCount > Um::ItemsInvolvedLimit)
- tooltip = Um::ItemsInvolved2 + "\n";
- for (uint a=0; a < docSelectionCount; ++a)
- {
- currItem = groupItems.at(a);
- ss->set(QString("item%1").arg(a), currItem->uniqueNr);
- ss->set(QString("tableitem%1").arg(a), currItem->isTableItem);
- if (docSelectionCount <= Um::ItemsInvolvedLimit)
- tooltip += "\t" + currItem->getUName() + "\n";
- currItem->isTableItem = false;
- currItem->setSelected(true);
- }
- undoManager->action(this, ss, Um::SelectionGroup, Um::IGroup);
- }
- if (undoTransaction)
- {
- undoTransaction->commit();
- delete undoTransaction;
- undoTransaction = NULL;
- }
- double x, y, w, h;
- itemSelection->connectItemToGUI();
- itemSelection->getGroupRect(&x, &y, &w, &h);
- emit docChanged();
- m_ScMW->HaveNewSel(itemSelection->itemAt(0)->itemType());
- regionsChanged()->update(QRectF(x-5, y-5, w+10, h+10));
- }
+ currItem = groupItems.at(a);
+ ss->set(QString("item%1").arg(a), currItem->uniqueNr);
+ ss->set(QString("tableitem%1").arg(a), currItem->isTableItem);
+ if (docSelectionCount <= Um::ItemsInvolvedLimit)
+ tooltip += "\t" + currItem->getUName() + "\n";
+ currItem->isTableItem = false;
+ currItem->setSelected(true);
+ }
+ undoManager->action(this, ss, Um::SelectionGroup, Um::IGroup);
+ }
+ if (undoTransaction)
+ {
+ undoTransaction->commit();
+ delete undoTransaction;
+ undoTransaction = NULL;
+ }
+ double x, y, w, h;
+ itemSelection->connectItemToGUI();
+ itemSelection->getGroupRect(&x, &y, &w, &h);
+ emit docChanged();
+ m_ScMW->HaveNewSel(itemSelection->itemAt(0)->itemType());
+ regionsChanged()->update(QRectF(x-5, y-5, w+10, h+10));
}
void ScribusDoc::itemSelection_UniteItems(Selection* /*customSelection*/)
More information about the scribus-commit
mailing list