diff options
author | brenda-br | 2023-02-02 19:12:02 +0530 |
---|---|---|
committer | brenda-br | 2023-02-02 19:12:02 +0530 |
commit | 4ac334851d1ceb92a582d3cfad40b0c0536899f1 (patch) | |
tree | e8fa128568e8d63cc305e50c2599387ee8c3f8b1 | |
parent | 4aea2c78d080aba7f686a6385f06459c76e63317 (diff) | |
download | Chemical-PFD-4ac334851d1ceb92a582d3cfad40b0c0536899f1.tar.gz Chemical-PFD-4ac334851d1ceb92a582d3cfad40b0c0536899f1.tar.bz2 Chemical-PFD-4ac334851d1ceb92a582d3cfad40b0c0536899f1.zip |
Fix #26 Node Line added after undoing delete action
-rw-r--r-- | src/main/python/utils/graphics.py | 12 | ||||
-rw-r--r-- | src/main/python/utils/undo.py | 1 |
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) |