From 6772ab7c10214b816b74d36b37d8ddf68230da5a Mon Sep 17 00:00:00 2001 From: sumit Date: Wed, 10 Jun 2020 08:50:29 +0530 Subject: fix remove of line with item --- src/main/python/shapes/shapes.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/main/python/shapes/shapes.py') diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py index a795f6a..fe92938 100644 --- a/src/main/python/shapes/shapes.py +++ b/src/main/python/shapes/shapes.py @@ -203,6 +203,15 @@ class LineGripItem(GripItem): self.setFlag(QGraphicsItem.ItemIsSelectable, True) self.setPen(QPen(QColor("black"), -1)) + def itemChange(self, change, value): + """ + Moves position of grip item on resize + """ + if change == QGraphicsItem.ItemSceneHasChanged and not self.scene(): + if self.line and self.line.scene(): + self.line.scene().removeItem(self.line) + return super(LineGripItem, self).itemChange(change, value) + def point(self, index): """ yields a list of positions of grip items in a node item @@ -439,23 +448,13 @@ class NodeItem(QGraphicsSvgItem): self.updateLineGripItem() self.updateSizeGripItem() return - if change == QGraphicsItem.ItemSceneHasChanged: + if change == QGraphicsItem.ItemSceneHasChanged and self.scene(): self.addGripItem() self.updateLineGripItem() self.updateSizeGripItem() return return super(NodeItem, self).itemChange(change, value) - def removeFromCanvas(self): - """This function is used to remove item from canvas - :return: - """ - for item in self.lineGripItems: - item.removeConnectedLines() - for item in self.sizeGripItems: - item.removeFromCanvas() - self.scene().removeItem(self) - def hoverEnterEvent(self, event): """defines shape highlighting on Mouse Over """ -- cgit