Commit c3e05931 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

network: Move on graph with mouse.

Showing with 17 additions and 1 deletion
+17 -1
...@@ -256,6 +256,9 @@ class GraphWidget(QGraphicsView): ...@@ -256,6 +256,9 @@ class GraphWidget(QGraphicsView):
self.edge_items = [] self.edge_items = []
self.texts = {} self.texts = {}
self.m_origin_x = 0.0
self.m_origin_y = 0.0
scene = QGraphicsScene(self) scene = QGraphicsScene(self)
scene.setItemIndexMethod(QGraphicsScene.NoIndex) scene.setItemIndexMethod(QGraphicsScene.NoIndex)
scene.setSceneRect(0, 0, 2000, 2000) scene.setSceneRect(0, 0, 2000, 2000)
...@@ -673,7 +676,20 @@ class GraphWidget(QGraphicsView): ...@@ -673,7 +676,20 @@ class GraphWidget(QGraphicsView):
self.tmp_line.dest = pos self.tmp_line.dest = pos
self.tmp_line.update() self.tmp_line.update()
# If state is "move" propagate event # If state is "move"
if self._state == "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() self.update()
super(GraphWidget, self).mouseMoveEvent(event) super(GraphWidget, self).mouseMoveEvent(event)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment