summaryrefslogtreecommitdiff
path: root/src/main/python/utils
diff options
context:
space:
mode:
authorpravindalve2020-06-03 11:00:07 +0530
committerGitHub2020-06-03 11:00:07 +0530
commit373a1072b7bb95b37397e2c6df861595bb5813ac (patch)
treeca122103eaa3c9fae7a9aedcca03a3c9036c50f5 /src/main/python/utils
parentac63205a7d02185f4a917db74bf0964691bf20ea (diff)
parent7ae4201c7539820108e991ff7df1a710e1387c13 (diff)
downloadChemical-PFD-373a1072b7bb95b37397e2c6df861595bb5813ac.tar.gz
Chemical-PFD-373a1072b7bb95b37397e2c6df861595bb5813ac.tar.bz2
Chemical-PFD-373a1072b7bb95b37397e2c6df861595bb5813ac.zip
Merge pull request #6 from Blakeinstein/master
Advance method
Diffstat (limited to 'src/main/python/utils')
-rw-r--r--src/main/python/utils/graphics.py7
-rw-r--r--src/main/python/utils/undo.py1
2 files changed, 8 insertions, 0 deletions
diff --git a/src/main/python/utils/graphics.py b/src/main/python/utils/graphics.py
index a997a30..27e02c4 100644
--- a/src/main/python/utils/graphics.py
+++ b/src/main/python/utils/graphics.py
@@ -86,9 +86,15 @@ class customScene(QGraphicsScene):
def __init__(self, *args, parent=None):
super(customScene, self).__init__(*args, parent=parent)
+ self.setItemIndexMethod(QGraphicsScene.NoIndex)
+
self.undoStack = QUndoStack(self) #Used to store undo-redo moves
self.createActions() #creates necessary actions that need to be called for undo-redo
+ def update(self, *args):
+ self.advance()
+ return super(customScene, self).update(*args)
+
def createActions(self):
# helper function to create delete, undo and redo shortcuts
self.deleteAction = QAction("Delete Item", self)
@@ -114,6 +120,7 @@ class customScene(QGraphicsScene):
def itemMoved(self, movedItem, lastPos):
#item move event, checks if item is moved
self.undoStack.push(moveCommand(movedItem, lastPos))
+ self.advance()
def addItemPlus(self, item):
# extended add item method, so that a corresponding undo action is also pushed
diff --git a/src/main/python/utils/undo.py b/src/main/python/utils/undo.py
index cf539e7..4a9f3dd 100644
--- a/src/main/python/utils/undo.py
+++ b/src/main/python/utils/undo.py
@@ -36,6 +36,7 @@ class addCommand(QUndoCommand):
self.scene.addItem(self.diagramItem)
self.diagramItem.setPos(self.itemPos)
self.scene.clearSelection()
+ # print(self.diagramItem)
self.scene.update()
class deleteCommand(QUndoCommand):