r19320 by jghali - refactoring of OutlineWidget::dropEvent() to improve readability
scribus-commit
scribus-commit at lists.scribus.net
Sun Jul 6 13:59:26 UTC 2014
Author: jghali
Date: Sun Jul 6 13:59:26 2014
New Revision: 19320
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19320
Log:
refactoring of OutlineWidget::dropEvent() to improve readability
Modified:
trunk/Scribus/scribus/ui/outlinepalette.cpp
Modified: trunk/Scribus/scribus/ui/outlinepalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19320&path=/trunk/Scribus/scribus/ui/outlinepalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/outlinepalette.cpp (original)
+++ trunk/Scribus/scribus/ui/outlinepalette.cpp Sun Jul 6 13:59:26 2014
@@ -99,138 +99,138 @@
haveLayers = true;
itemPar = (OutlineTreeItem*)itemPar->parent();
}
+
QTreeWidget::dropEvent(e);
- if (it != NULL)
- {
- OutlineTreeItem *item = (OutlineTreeItem*)it;
- if (item != NULL)
- {
- OutlineTreeItem *itemPl = (OutlineTreeItem*)it->parent();
- OutlineTreeItem *itemPg;
+ if (it == NULL)
+ return;
+ OutlineTreeItem *item = (OutlineTreeItem*)it;
+ if (item == NULL)
+ return;
+
+ OutlineTreeItem *itemPl = (OutlineTreeItem*)it->parent();
+ OutlineTreeItem *itemPg;
+ if (itemPl->type == 5)
+ {
+ itemPg = (OutlineTreeItem*)it->parent()->parent();
+ }
+ else if (itemPl->type == 2)
+ {
+ itemPg = (OutlineTreeItem*)it->parent();
+ if (haveLayers)
+ {
+ itemPl = (OutlineTreeItem*)itemPg->child(0);
+ itemPg->removeChild(it);
+ itemPl->addChild(it);
+ }
+ }
+ else
+ {
+ itemPg = (OutlineTreeItem*)it->parent();
+ while (itemPg->type != 2)
+ {
+ itemPg = (OutlineTreeItem*)itemPg->parent();
+ }
+ }
+ if (itemPl->indexOfChild(it) != itemPl->childCount() - 1)
+ {
+ OutlineTreeItem *itemBe = (OutlineTreeItem*)itemPl->child(itemPl->indexOfChild(it) + 1);
+ if ((itemBe->type == 1) || (itemBe->type == 3) || (itemBe->type == 4))
+ {
+ if (item->PageItemObject->isGroupChild())
+ item->DocObject->removeFromGroup(item->PageItemObject);
+ else
+ item->DocObject->Items->removeOne(item->PageItemObject);
+ if (itemBe->PageItemObject->isGroupChild())
+ {
+ PageItem* group = itemBe->PageItemObject->Parent;
+ int d = group->groupItemList.indexOf(itemBe->PageItemObject);
+ double xx = item->PageItemObject->xPos() - itemPar->PageObject->xOffset() + itemPg->PageObject->xOffset();
+ double yy = item->PageItemObject->yPos() - itemPar->PageObject->yOffset() + itemPg->PageObject->yOffset();
+ item->PageItemObject->setXYPos(xx, yy);
+ item->DocObject->addToGroup(group, item->PageItemObject);
+ group->groupItemList.insert(d, item->PageItemObject);
+ item->PageItemObject->setLayer(group->LayerID);
+ }
+ else
+ {
+ int d = item->DocObject->Items->indexOf(itemBe->PageItemObject);
+ item->DocObject->Items->insert(d+1, item->PageItemObject);
+ if (itemPl->type == 5)
+ item->PageItemObject->setLayer(itemPl->LayerID);
+ double xx = item->PageItemObject->xPos() - itemPar->PageObject->xOffset() + itemPg->PageObject->xOffset();
+ double yy = item->PageItemObject->yPos() - itemPar->PageObject->yOffset() + itemPg->PageObject->yOffset();
+ item->PageItemObject->setXYPos(xx, yy);
+ }
+ item->PageItemObject->setRedrawBounding();
+ item->DocObject->setModified(true);
+ item->DocObject->scMW()->showLayer();
+ item->DocObject->scMW()->closeActiveWindowMasterPageEditor();
+ if (item->PageItemObject->isGroup())
+ {
+ item->DocObject->GroupOnPage(item->PageItemObject);
+ item->DocObject->scMW()->selectItemsFromOutlines(item->PageItemObject, false);
+ }
+ else
+ {
+ item->PageItemObject->OwnPage = item->DocObject->OnPage(item->PageItemObject);
+ item->DocObject->scMW()->selectItemsFromOutlines(item->PageItemObject, true);
+ }
+ QList<QTreeWidgetItem*> selList;
+ selList.append(it);
+ selectItems(selList);
+ }
+ }
+ else
+ {
+// itemPl->insertChild(0, itemPl->takeChild(itemPl->indexOfChild(it)));
+ if ((itemPl->type == 2) || (itemPl->type == 5))
+ {
+ if (item->PageItemObject->isGroupChild())
+ {
+ item->DocObject->removeFromGroup(item->PageItemObject);
+ item->DocObject->Items->append(item->PageItemObject);
+ }
if (itemPl->type == 5)
- {
- itemPg = (OutlineTreeItem*)it->parent()->parent();
- }
- else if (itemPl->type == 2)
- {
- itemPg = (OutlineTreeItem*)it->parent();
- if (haveLayers)
- {
- itemPl = (OutlineTreeItem*)itemPg->child(0);
- itemPg->removeChild(it);
- itemPl->addChild(it);
- }
- }
- else
- {
- itemPg = (OutlineTreeItem*)it->parent();
- while (itemPg->type != 2)
- {
- itemPg = (OutlineTreeItem*)itemPg->parent();
- }
- }
- if (itemPl->indexOfChild(it) != itemPl->childCount() - 1)
- {
- OutlineTreeItem *itemBe = (OutlineTreeItem*)itemPl->child(itemPl->indexOfChild(it) + 1);
- if ((itemBe->type == 1) || (itemBe->type == 3) || (itemBe->type == 4))
- {
- if (item->PageItemObject->isGroupChild())
- item->DocObject->removeFromGroup(item->PageItemObject);
- else
- item->DocObject->Items->removeOne(item->PageItemObject);
- if (itemBe->PageItemObject->isGroupChild())
- {
- PageItem* group = itemBe->PageItemObject->Parent;
- int d = group->groupItemList.indexOf(itemBe->PageItemObject);
- double xx = item->PageItemObject->xPos() - itemPar->PageObject->xOffset() + itemPg->PageObject->xOffset();
- double yy = item->PageItemObject->yPos() - itemPar->PageObject->yOffset() + itemPg->PageObject->yOffset();
- item->PageItemObject->setXYPos(xx, yy);
- item->DocObject->addToGroup(group, item->PageItemObject);
- group->groupItemList.insert(d, item->PageItemObject);
- item->PageItemObject->setLayer(group->LayerID);
- }
- else
- {
- int d = item->DocObject->Items->indexOf(itemBe->PageItemObject);
- item->DocObject->Items->insert(d+1, item->PageItemObject);
- if (itemPl->type == 5)
- item->PageItemObject->setLayer(itemPl->LayerID);
- double xx = item->PageItemObject->xPos() - itemPar->PageObject->xOffset() + itemPg->PageObject->xOffset();
- double yy = item->PageItemObject->yPos() - itemPar->PageObject->yOffset() + itemPg->PageObject->yOffset();
- item->PageItemObject->setXYPos(xx, yy);
- }
- item->PageItemObject->setRedrawBounding();
- item->DocObject->setModified(true);
- item->DocObject->scMW()->showLayer();
- item->DocObject->scMW()->closeActiveWindowMasterPageEditor();
- if (item->PageItemObject->isGroup())
- {
- item->DocObject->GroupOnPage(item->PageItemObject);
- item->DocObject->scMW()->selectItemsFromOutlines(item->PageItemObject, false);
- }
- else
- {
- item->PageItemObject->OwnPage = item->DocObject->OnPage(item->PageItemObject);
- item->DocObject->scMW()->selectItemsFromOutlines(item->PageItemObject, true);
- }
- QList<QTreeWidgetItem*> selList;
- selList.append(it);
- selectItems(selList);
- }
- }
- else
- {
- // itemPl->insertChild(0, itemPl->takeChild(itemPl->indexOfChild(it)));
- if ((itemPl->type == 2) || (itemPl->type == 5))
- {
- if (item->PageItemObject->isGroupChild())
- {
- item->DocObject->removeFromGroup(item->PageItemObject);
- item->DocObject->Items->append(item->PageItemObject);
- }
- if (itemPl->type == 5)
- item->PageItemObject->setLayer(itemPl->LayerID);
- double xx = item->PageItemObject->xPos() - itemPar->PageObject->xOffset() + itemPg->PageObject->xOffset();
- double yy = item->PageItemObject->yPos() - itemPar->PageObject->yOffset() + itemPg->PageObject->yOffset();
- item->PageItemObject->setXYPos(xx, yy);
- }
+ item->PageItemObject->setLayer(itemPl->LayerID);
+ double xx = item->PageItemObject->xPos() - itemPar->PageObject->xOffset() + itemPg->PageObject->xOffset();
+ double yy = item->PageItemObject->yPos() - itemPar->PageObject->yOffset() + itemPg->PageObject->yOffset();
+ item->PageItemObject->setXYPos(xx, yy);
+ }
+ else
+ {
+ OutlineTreeItem *itemBe = (OutlineTreeItem*)it->parent();
+ if ((itemBe->type == 1) || (itemBe->type == 3) || (itemBe->type == 4))
+ {
+ if (item->PageItemObject->isGroupChild())
+ item->DocObject->removeFromGroup(item->PageItemObject);
else
- {
- OutlineTreeItem *itemBe = (OutlineTreeItem*)it->parent();
- if ((itemBe->type == 1) || (itemBe->type == 3) || (itemBe->type == 4))
- {
- if (item->PageItemObject->isGroupChild())
- item->DocObject->removeFromGroup(item->PageItemObject);
- else
- item->DocObject->Items->removeOne(item->PageItemObject);
- PageItem* group = itemBe->PageItemObject;
- double xx = item->PageItemObject->xPos() - itemPar->PageObject->xOffset() + itemPg->PageObject->xOffset();
- double yy = item->PageItemObject->yPos() - itemPar->PageObject->yOffset() + itemPg->PageObject->yOffset();
- item->PageItemObject->setXYPos(xx, yy);
- item->DocObject->addToGroup(group, item->PageItemObject);
- group->groupItemList.append(item->PageItemObject);
- item->PageItemObject->setLayer(group->LayerID);
- }
- }
- item->PageItemObject->setRedrawBounding();
- item->DocObject->setModified(true);
- item->DocObject->scMW()->showLayer();
- item->DocObject->scMW()->closeActiveWindowMasterPageEditor();
- if (item->PageItemObject->isGroup())
- {
- item->DocObject->GroupOnPage(item->PageItemObject);
- item->DocObject->scMW()->selectItemsFromOutlines(item->PageItemObject, false);
- }
- else
- {
- item->PageItemObject->OwnPage = item->DocObject->OnPage(item->PageItemObject);
- item->DocObject->scMW()->selectItemsFromOutlines(item->PageItemObject, true);
- }
- QList<QTreeWidgetItem*> selList;
- selList.append(it);
- selectItems(selList);
- }
- }
+ item->DocObject->Items->removeOne(item->PageItemObject);
+ PageItem* group = itemBe->PageItemObject;
+ double xx = item->PageItemObject->xPos() - itemPar->PageObject->xOffset() + itemPg->PageObject->xOffset();
+ double yy = item->PageItemObject->yPos() - itemPar->PageObject->yOffset() + itemPg->PageObject->yOffset();
+ item->PageItemObject->setXYPos(xx, yy);
+ item->DocObject->addToGroup(group, item->PageItemObject);
+ group->groupItemList.append(item->PageItemObject);
+ item->PageItemObject->setLayer(group->LayerID);
+ }
+ }
+ item->PageItemObject->setRedrawBounding();
+ item->DocObject->setModified(true);
+ item->DocObject->scMW()->showLayer();
+ item->DocObject->scMW()->closeActiveWindowMasterPageEditor();
+ if (item->PageItemObject->isGroup())
+ {
+ item->DocObject->GroupOnPage(item->PageItemObject);
+ item->DocObject->scMW()->selectItemsFromOutlines(item->PageItemObject, false);
+ }
+ else
+ {
+ item->PageItemObject->OwnPage = item->DocObject->OnPage(item->PageItemObject);
+ item->DocObject->scMW()->selectItemsFromOutlines(item->PageItemObject, true);
+ }
+ QList<QTreeWidgetItem*> selList;
+ selList.append(it);
+ selectItems(selList);
}
}
More information about the scribus-commit
mailing list