MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / undo

Method undo

src/domain/UBGraphicsItemUndoCommand.cpp:88–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88void 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 }

Callers

nothing calls this directly

Calls 15

freezeW3CWidgetMethod · 0.80
strokesGroupMethod · 0.80
removeFromGroupMethod · 0.80
setAsBackgroundObjectMethod · 0.80
addToGroupMethod · 0.80
itemForUuidMethod · 0.80
updateSelectionFrameMethod · 0.80
setSelectedMethod · 0.45
typeMethod · 0.45
removeItemMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected