summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/python/utils/graphics.py12
-rw-r--r--src/main/python/utils/undo.py1
2 files changed, 13 insertions, 0 deletions
diff --git a/src/main/python/utils/graphics.py b/src/main/python/utils/graphics.py
index bb113ce..979841f 100644
--- a/src/main/python/utils/graphics.py
+++ b/src/main/python/utils/graphics.py
@@ -105,6 +105,12 @@ class CustomScene(QGraphicsScene):
# (slot) used to delete all selected items, and add undo action for each of them
if self.selectedItems():
for item in self.selectedItems():
+ self.count = 0
+ if(issubclass(item.__class__,shapes.NodeItem)):
+ for i in item.lineGripItems:
+ for j in i.lines:
+ self.count+=1
+ self.undoStack.push(deleteCommand(j, self))
self.undoStack.push(deleteCommand(item, self))
def itemMoved(self, movedItem, lastPos):
@@ -135,3 +141,9 @@ class CustomScene(QGraphicsScene):
self.itemMoved(self.movingItem, self.oldPos)
self.movingItem = None #clear movingitem reference
return super(CustomScene, self).mouseReleaseEvent(event)
+ def reInsertLines(self):
+ currentIndex = self.undoStack.index()
+ index = self.count+1
+ if(self.count!=0):
+ self.count-=1
+ self.undoStack.command(currentIndex-index).undo()
diff --git a/src/main/python/utils/undo.py b/src/main/python/utils/undo.py
index 6a46b27..090ce9d 100644
--- a/src/main/python/utils/undo.py
+++ b/src/main/python/utils/undo.py
@@ -54,6 +54,7 @@ class deleteCommand(QUndoCommand):
self.scene.addItem(self.diagramItem)
self.scene.update()
self.scene.advance()
+ self.scene.reInsertLines()
def redo(self):
self.scene.removeItem(self.diagramItem)