| 86 | } |
| 87 | |
| 88 | void UBGraphicsItemUndoCommand::undo() |
| 89 | { |
| 90 | if (!mScene){ |
| 91 | return; |
| 92 | } |
| 93 | |
| 94 | QSetIterator<QGraphicsItem*> itAdded(mAddedItems); |
| 95 | while (itAdded.hasNext()) |
| 96 | { |
| 97 | QGraphicsItem* item = itAdded.next(); |
| 98 | |
| 99 | UBApplication::boardController->freezeW3CWidget(item, true); |
| 100 | item->setSelected(false); |
| 101 | |
| 102 | QTransform t; |
| 103 | bool bApplyTransform = false; |
| 104 | UBGraphicsPolygonItem *polygonItem = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item); |
| 105 | if (polygonItem){ |
| 106 | if (polygonItem->strokesGroup() |
| 107 | && polygonItem->strokesGroup()->parentItem() |
| 108 | && UBGraphicsGroupContainerItem::Type == polygonItem->strokesGroup()->parentItem()->type()) |
| 109 | { |
| 110 | bApplyTransform = true; |
| 111 | t = polygonItem->sceneTransform(); |
| 112 | } |
| 113 | else if (polygonItem->strokesGroup()) |
| 114 | polygonItem->resetTransform(); |
| 115 | |
| 116 | polygonItem->strokesGroup()->removeFromGroup(polygonItem); |
| 117 | } |
| 118 | mScene->removeItem(item); |
| 119 | |
| 120 | if (bApplyTransform) |
| 121 | polygonItem->setTransform(t); |
| 122 | |
| 123 | } |
| 124 | |
| 125 | QSetIterator<QGraphicsItem*> itRemoved(mRemovedItems); |
| 126 | while (itRemoved.hasNext()) |
| 127 | { |
| 128 | QGraphicsItem* item = itRemoved.next(); |
| 129 | if (item) |
| 130 | { |
| 131 | if (itemLayerType::BackgroundItem == item->data(UBGraphicsItemData::itemLayerType)) |
| 132 | mScene->setAsBackgroundObject(item); |
| 133 | else |
| 134 | mScene->addItem(item); |
| 135 | |
| 136 | if (UBGraphicsPolygonItem::Type == item->type()) |
| 137 | { |
| 138 | UBGraphicsPolygonItem *polygonItem = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item); |
| 139 | if (polygonItem) |
| 140 | { |
| 141 | mScene->removeItem(polygonItem); |
| 142 | mScene->removeItemFromDeletion(polygonItem); |
| 143 | polygonItem->strokesGroup()->addToGroup(polygonItem); |
| 144 | } |
| 145 | } |
nothing calls this directly
no test coverage detected