mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
network: Move on graph with mouse.
This commit is contained in:
1 parent
ee8492fcb5
commit
c3e0593137
1 file changed
+17
-1
@@ -256,6 +256,9 @@ class GraphWidget(QGraphicsView):
|
||||
self.edge_items = []
|
||||
self.texts = {}
|
||||
|
||||
self.m_origin_x = 0.0
|
||||
self.m_origin_y = 0.0
|
||||
|
||||
scene = QGraphicsScene(self)
|
||||
scene.setItemIndexMethod(QGraphicsScene.NoIndex)
|
||||
scene.setSceneRect(0, 0, 2000, 2000)
|
||||
@@ -673,7 +676,20 @@ class GraphWidget(QGraphicsView):
|
||||
self.tmp_line.dest = pos
|
||||
self.tmp_line.update()
|
||||
|
||||
# If state is "move" propagate event
|
||||
# If state is "move"
|
||||
if self._state == "move":
|
||||
# Move on scene
|
||||
if (not self.selected_item() and
|
||||
event.buttons() & Qt.LeftButton):
|
||||
old_p = self.mapToScene(self.m_origin_x, self.m_origin_y)
|
||||
new_p = self.mapToScene(event.pos())
|
||||
translation = new_p - old_p
|
||||
|
||||
self.translate(translation.x(), translation.y())
|
||||
|
||||
self.m_origin_x = event.x()
|
||||
self.m_origin_y = event.y()
|
||||
|
||||
# Propagate event
|
||||
self.update()
|
||||
super(GraphWidget, self).mouseMoveEvent(event)
|
||||
Reference in new issue
Block a user