mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Network: Add undo command for node move.
This commit is contained in:
1 parent
a7945eea9a
commit
eb6d218b8e
2 files changed
+33
-3
No files matched your search
@@ -669,14 +669,15 @@ class GraphWidget(QGraphicsView):
|
||||
if self._state == "move":
|
||||
self._selected_new_edge_src_node = None
|
||||
|
||||
self.mouse_origin_x = pos.x()
|
||||
self.mouse_origin_y = pos.y()
|
||||
|
||||
items = self.items(event.pos())
|
||||
if items and type(items[0]) == EdgeItem:
|
||||
edge = items[0]
|
||||
if edge:
|
||||
self.set_current_edge(edge)
|
||||
elif items and type(items[0]) == NodeItem:
|
||||
self._mouse_origin_x = pos.x()
|
||||
self._mouse_origin_y = pos.y()
|
||||
self._current_moved_node = items[0]
|
||||
|
||||
# Add nodes and edges
|
||||
elif self._state == "add":
|
||||
@@ -712,6 +713,17 @@ class GraphWidget(QGraphicsView):
|
||||
def mouseReleaseEvent(self, event):
|
||||
self.clicked = False
|
||||
|
||||
if self._state == "move":
|
||||
pos = self.mapToScene(event.pos())
|
||||
self._undo.push(
|
||||
SetNodePosCommand(
|
||||
self._current_moved_node,
|
||||
(pos.x(), pos.y()),
|
||||
(self._mouse_origin_x,
|
||||
self._mouse_origin_y)
|
||||
)
|
||||
)
|
||||
|
||||
self.update()
|
||||
super(GraphWidget, self).mouseReleaseEvent(event)
|
||||
|
||||
|
||||
Reference in new issue
Block a user