diff options
author | brenda-br | 2023-02-12 16:37:32 +0530 |
---|---|---|
committer | brenda-br | 2023-02-12 16:37:32 +0530 |
commit | d44ab6e457741c9759efe51cf7e9c29c82221440 (patch) | |
tree | 235bdc283fd33ecafc0878c583cd73c4378ed3e0 /src/main/python/utils/undo.py | |
parent | 5e9fdd9682bb41b952eb39b5869cc4dc5fc59ecb (diff) | |
download | Chemical-PFD-d44ab6e457741c9759efe51cf7e9c29c82221440.tar.gz Chemical-PFD-d44ab6e457741c9759efe51cf7e9c29c82221440.tar.bz2 Chemical-PFD-d44ab6e457741c9759efe51cf7e9c29c82221440.zip |
Fix #26 Fix on Undo Command
Diffstat (limited to 'src/main/python/utils/undo.py')
-rw-r--r-- | src/main/python/utils/undo.py | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/main/python/utils/undo.py b/src/main/python/utils/undo.py index 8e21fe7..ea41d0b 100644 --- a/src/main/python/utils/undo.py +++ b/src/main/python/utils/undo.py @@ -50,19 +50,20 @@ class deleteCommand(QUndoCommand): item.setSelected(False) self.diagramItem = item if(issubclass(self.diagramItem.__class__,shapes.Line)): - self.startGrip = self.diagramItem.startGripItem.parentItem() - self.endGrip = self.diagramItem.endGripItem.parentItem() + self.startGrip = item.startGripItem.parentItem() + self.endGrip = item.endGripItem.parentItem() self.indexLGS,self.indexLGE = self.findLGIndex() self.setText(f"Delete {objectName(self.diagramItem)} at {self.diagramItem.pos().x()}, {self.diagramItem.y()}") def undo(self): - self.scene.addItem(self.diagramItem) - self.scene.update() - self.scene.advance() - self.scene.reInsertLines() - if(issubclass(self.diagramItem.__class__,shapes.Line)): - self.reconnectLines() - + if self.diagramItem not in self.scene.items(): + self.scene.addItem(self.diagramItem) + self.scene.update() + self.scene.advance() + self.scene.reInsertLines() + if(issubclass(self.diagramItem.__class__,shapes.Line)): + self.reconnectLines() + def redo(self): self.scene.removeItem(self.diagramItem) self.scene.advance() @@ -74,24 +75,20 @@ class deleteCommand(QUndoCommand): endIndex = None for indexLG,i in enumerate(self.startGrip.lineGripItems): for j in i.lines: - if(j == self.diagramItem): + if j == self.diagramItem: startIndex = indexLG for indexLG,i in enumerate(self.endGrip.lineGripItems): for j in i.lines: - if(j == self.diagramItem): + if j == self.diagramItem: endIndex = indexLG return startIndex,endIndex def reconnectLines(self): - try: + if self.diagramItem not in self.startGrip.lineGripItems[self.indexLGS].lines: self.startGrip.lineGripItems[self.indexLGS].lines.append(self.diagramItem) - except: - pass - try: + if self.diagramItem not in self.endGrip.lineGripItems[self.indexLGE].lines: self.endGrip.lineGripItems[self.indexLGE].lines.append(self.diagramItem) - except: - pass - + class moveCommand(QUndoCommand): """ QUndoCommand for move item event |