summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorbrenda-br2023-02-06 20:56:13 +0530
committerbrenda-br2023-02-06 20:56:13 +0530
commit5e9fdd9682bb41b952eb39b5869cc4dc5fc59ecb (patch)
tree34914119d0abb3e434aa8bab098d8a9b3b5cc340 /src/main
parent42942f4c0f6aee658ffd2c374588c402debca33d (diff)
downloadChemical-PFD-5e9fdd9682bb41b952eb39b5869cc4dc5fc59ecb.tar.gz
Chemical-PFD-5e9fdd9682bb41b952eb39b5869cc4dc5fc59ecb.tar.bz2
Chemical-PFD-5e9fdd9682bb41b952eb39b5869cc4dc5fc59ecb.zip
Undeletable Line Grips
Diffstat (limited to 'src/main')
-rw-r--r--src/main/python/utils/graphics.py11
-rw-r--r--src/main/python/utils/undo.py11
2 files changed, 17 insertions, 5 deletions
diff --git a/src/main/python/utils/graphics.py b/src/main/python/utils/graphics.py
index a6910ae..c9dbed7 100644
--- a/src/main/python/utils/graphics.py
+++ b/src/main/python/utils/graphics.py
@@ -105,13 +105,17 @@ 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():
+ if(issubclass(item.__class__,shapes.LineGripItem) or issubclass(item.__class__,shapes.SizeGripItem) ):
+ itemToDelete = item.parentItem()
+ else:
+ itemToDelete = item
self.count = 0
- if(issubclass(item.__class__,shapes.NodeItem)):
- for i in item.lineGripItems:
+ if(issubclass(itemToDelete.__class__,shapes.NodeItem)):
+ for i in itemToDelete.lineGripItems:
for j in i.lines:
self.count+=1
self.undoStack.push(deleteCommand(j, self))
- self.undoStack.push(deleteCommand(item, self))
+ self.undoStack.push(deleteCommand(itemToDelete, self))
def itemMoved(self, movedItem, lastPos):
#item move event, checks if item is moved
@@ -141,6 +145,7 @@ 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
diff --git a/src/main/python/utils/undo.py b/src/main/python/utils/undo.py
index 2f28964..8e21fe7 100644
--- a/src/main/python/utils/undo.py
+++ b/src/main/python/utils/undo.py
@@ -83,8 +83,15 @@ class deleteCommand(QUndoCommand):
return startIndex,endIndex
def reconnectLines(self):
- self.startGrip.lineGripItems[self.indexLGS].lines.append(self.diagramItem)
- self.endGrip.lineGripItems[self.indexLGE].lines.append(self.diagramItem)
+ try:
+ self.startGrip.lineGripItems[self.indexLGS].lines.append(self.diagramItem)
+ except:
+ pass
+ try:
+ self.endGrip.lineGripItems[self.indexLGE].lines.append(self.diagramItem)
+ except:
+ pass
+
class moveCommand(QUndoCommand):
"""
QUndoCommand for move item event