Network: Fix reach selection where the study is read only.

disable_edition_parent_scenario
Pierre-Antoine 2026-05-22 10:53:51 +02:00
parent 64d2b2678a
commit e26b170b05
1 changed files with 39 additions and 38 deletions

View File

@ -925,9 +925,11 @@ class GraphWidget(QGraphicsView):
self.scale(scaleFactor, scaleFactor) self.scale(scaleFactor, scaleFactor)
def mousePressEvent(self, event): def mousePressEvent(self, event):
if self._only_display or self.graph._status.is_read_only(): if self._only_display:
return return
locked = self.graph._status.is_read_only()
pos = self.mapToScene(event.pos()) pos = self.mapToScene(event.pos())
self.clicked = True self.clicked = True
@ -936,9 +938,6 @@ class GraphWidget(QGraphicsView):
super(GraphWidget, self).mousePressEvent(event) super(GraphWidget, self).mousePressEvent(event)
return return
if self.graph._status.is_read_only():
return
# Move item and select edge item # Move item and select edge item
if self._state == "move": if self._state == "move":
self._selected_new_edge_src_node = None self._selected_new_edge_src_node = None
@ -948,13 +947,15 @@ class GraphWidget(QGraphicsView):
edge = items[0] edge = items[0]
if edge: if edge:
self.set_current_edge(edge) self.set_current_edge(edge)
elif items and type(items[0]) is NodeItem: if not locked:
if items and type(items[0]) is NodeItem:
self._mouse_origin_x = pos.x() self._mouse_origin_x = pos.x()
self._mouse_origin_y = pos.y() self._mouse_origin_y = pos.y()
self._current_moved_node = items[0] self._current_moved_node = items[0]
if not locked:
# Add nodes and edges # Add nodes and edges
elif self._state == "add": if self._state == "add":
items = self.items(event.pos()) items = self.items(event.pos())
nodes = list(filter(lambda i: type(i) is NodeItem, items)) nodes = list(filter(lambda i: type(i) is NodeItem, items))
if not nodes: if not nodes:
@ -988,10 +989,12 @@ class GraphWidget(QGraphicsView):
def mouseReleaseEvent(self, event): def mouseReleaseEvent(self, event):
self.clicked = False self.clicked = False
if self._only_display or self.graph._status.is_read_only(): if self._only_display:
return return
if self._state == "move": locked = self.graph._status.is_read_only()
if not locked and self._state == "move":
if self._current_moved_node is not None: if self._current_moved_node is not None:
pos = self.mapToScene(event.pos()) pos = self.mapToScene(event.pos())
self._undo.push( self._undo.push(
@ -1007,10 +1010,8 @@ class GraphWidget(QGraphicsView):
super(GraphWidget, self).mouseReleaseEvent(event) super(GraphWidget, self).mouseReleaseEvent(event)
def mouseMoveEvent(self, event): def mouseMoveEvent(self, event):
if self.graph._status.is_read_only():
return
pos = self.mapToScene(event.pos()) pos = self.mapToScene(event.pos())
locked = self.graph._status.is_read_only()
# Selecte item on the fly # Selecte item on the fly
items = self.items(event.pos()) items = self.items(event.pos())