AdisTS: Fix the possibility to edit AdisTS windows on a parent scenario

disable_edition_parent_scenario
Dylan Jeannin 2026-05-22 16:47:02 +02:00
parent eed2ce4243
commit a78be47e2b
11 changed files with 115 additions and 37 deletions

View File

@ -89,6 +89,12 @@ class EditBoundaryConditionWindow(PamhyrWindow):
def setup_table(self):
table_headers = self._trad.get_dict("table_headers")
if self._study.is_editable():
editable_headers = self._trad.get_dict("table_headers")
else:
editable_headers = []
if self._data.type == "Concentration":
self._data.header = ["time", "concentration"]
else:
@ -108,7 +114,7 @@ class EditBoundaryConditionWindow(PamhyrWindow):
self._table = TableModel(
table_view=table,
table_headers=headers,
editable_headers=self._data.header,
editable_headers=editable_headers,
delegates={
# "time": self._delegate_time,
},
@ -141,9 +147,10 @@ class EditBoundaryConditionWindow(PamhyrWindow):
self.plot.draw()
def setup_connections(self):
self.find(QAction, "action_add").triggered.connect(self.add)
self.find(QAction, "action_del").triggered.connect(self.delete)
self.find(QAction, "action_sort").triggered.connect(self.sort)
if self._study.is_editable():
self.find(QAction, "action_add").triggered.connect(self.add)
self.find(QAction, "action_del").triggered.connect(self.delete)
self.find(QAction, "action_sort").triggered.connect(self.sort)
self._table.dataChanged.connect(self.update)
def update(self):

View File

@ -106,11 +106,16 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
parent=self
)
if self._study.is_editable():
editable_headers = self._trad.get_dict("table_headers")
else:
editable_headers = []
table = self.find(QTableView, f"tableView")
self._table = TableModel(
table_view=table,
table_headers=self._trad.get_dict("table_headers"),
editable_headers=["type", "node", "pol"],
editable_headers=editable_headers,
delegates={
"type": self._delegate_type,
"node": self._delegate_node,
@ -137,8 +142,10 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
self.graph_layout.addWidget(self.graph_widget)
def setup_connections(self):
self.find(QAction, "action_add").triggered.connect(self.add)
self.find(QAction, "action_del").triggered.connect(self.delete)
if self._study.is_editable():
self.find(QAction, "action_add").triggered.connect(self.add)
self.find(QAction, "action_del").triggered.connect(self.delete)
self.find(QAction, "action_edit").triggered.connect(self.edit)
def index_selected_row(self):

View File

@ -99,12 +99,17 @@ class D90AdisTSWindow(PamhyrWindow):
path_icons = os.path.join(self._get_ui_directory(), f"ressources")
if self._study.is_editable():
editable_headers = self._trad.get_dict("table_headers")
else:
editable_headers = []
table_default = self.find(QTableView, f"tableView")
self._table = D90TableDefaultModel(
table_view=table_default,
table_headers=self._trad.get_dict("table_headers"),
editable_headers=["name", "d90"],
editable_headers=editable_headers,
delegates={},
data=self._data,
undo=self._undo_stack,
@ -124,10 +129,15 @@ class D90AdisTSWindow(PamhyrWindow):
action_add = QAction(self)
action_add.setIcon(QIcon(os.path.join(path_icons, f"add.png")))
action_add.triggered.connect(self.add)
if self._study.is_editable():
action_add.triggered.connect(self.add)
action_delete = QAction(self)
action_delete.setIcon(QIcon(os.path.join(path_icons, f"del.png")))
action_delete.triggered.connect(self.delete)
if self._study.is_editable():
action_delete.triggered.connect(self.delete)
toolBar.addAction(action_add)
toolBar.addAction(action_delete)
@ -150,10 +160,15 @@ class D90AdisTSWindow(PamhyrWindow):
mode="rk"
)
if self._study.is_editable():
editable_headers_spec = self._trad.get_dict("table_headers_spec")
else:
editable_headers_spec = []
self._table_spec = D90TableModel(
table_view=self.table_spec,
table_headers=self._trad.get_dict("table_headers_spec"),
editable_headers=["name", "reach", "start_rk", "end_rk", "d90"],
editable_headers=editable_headers_spec,
delegates={
"reach": self._delegate_reach,
"start_rk": self._delegate_rk,

View File

@ -99,6 +99,11 @@ class DIFAdisTSWindow(PamhyrWindow):
table_default = self.find(QTableView, f"tableView")
if self._study.is_editable():
editable_headers = self._trad.get_dict("table_headers")
else:
editable_headers = []
self._delegate_method = ComboBoxDelegate(
trad=self._trad,
data=self._study.river,
@ -110,7 +115,7 @@ class DIFAdisTSWindow(PamhyrWindow):
self._table = DIFTableDefaultModel(
table_view=table_default,
table_headers=self._trad.get_dict("table_headers"),
editable_headers=["method", "dif", "b", "c"],
editable_headers=editable_headers,
delegates={
"method": self._delegate_method
},
@ -132,10 +137,14 @@ class DIFAdisTSWindow(PamhyrWindow):
action_add = QAction(self)
action_add.setIcon(QIcon(os.path.join(path_icons, f"add.png")))
action_add.triggered.connect(self.add)
if self._study.is_editable():
action_add.triggered.connect(self.add)
action_delete = QAction(self)
action_delete.setIcon(QIcon(os.path.join(path_icons, f"del.png")))
action_delete.triggered.connect(self.delete)
if self._study.is_editable():
action_delete.triggered.connect(self.delete)
toolBar.addAction(action_add)
toolBar.addAction(action_delete)
@ -158,11 +167,15 @@ class DIFAdisTSWindow(PamhyrWindow):
mode="rk"
)
if self._study.is_editable():
editable_headers_spec = self._trad.get_dict("table_headers_spec")
else:
editable_headers_spec = []
self._table_spec = DIFTableModel(
table_view=self.table_spec,
table_headers=self._trad.get_dict("table_headers_spec"),
editable_headers=["method", "reach", "start_rk",
"end_rk", "dif", "b", "c"],
editable_headers=editable_headers_spec,
delegates={
"method": self._delegate_method,
"reach": self._delegate_reach,

View File

@ -108,10 +108,15 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
table_default = self.find(QTableView, f"tableView")
if self._study.is_editable():
editable_headers = self._trad.get_dict("table_headers")
else:
editable_headers = []
self._table = InitialConditionTableDefaultModel(
table_view=table_default,
table_headers=self._trad.get_dict("table_headers"),
editable_headers=["name", "concentration", "eg", "em", "ed"],
editable_headers=editable_headers,
delegates={},
data=self._data,
undo=self._undo_stack,
@ -131,10 +136,14 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
action_add = QAction(self)
action_add.setIcon(QIcon(os.path.join(path_icons, f"add.png")))
action_add.triggered.connect(self.add)
if self._study.is_editable():
action_add.triggered.connect(self.add)
action_delete = QAction(self)
action_delete.setIcon(QIcon(os.path.join(path_icons, f"del.png")))
action_delete.triggered.connect(self.delete)
if self._study.is_editable():
action_delete.triggered.connect(self.delete)
toolBar.addAction(action_add)
toolBar.addAction(action_delete)
@ -157,12 +166,15 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
mode="rk"
)
if self._study.is_editable():
editable_headers_spec = self._trad.get_dict("table_headers_spec")
else:
editable_headers_spec = []
self._table_spec = InitialConditionTableModel(
table_view=self.table_spec,
table_headers=self._trad.get_dict("table_headers_spec"),
editable_headers=["name", "reach", "start_rk",
"end_rk", "concentration",
"eg", "em", "ed", "rate"],
editable_headers=editable_headers_spec,
delegates={
"reach": self._delegate_reach,
"start_rk": self._delegate_rk,

View File

@ -103,6 +103,11 @@ class EditLateralContributionAdisTSWindow(PamhyrWindow):
parent=self
)
if self._study.is_editable():
editable_headers = self._trad.get_dict("table_headers")
else:
editable_headers = []
headers = {}
table_headers = self._trad.get_dict("table_headers")
for h in self._data.header:
@ -112,7 +117,7 @@ class EditLateralContributionAdisTSWindow(PamhyrWindow):
self._table = TableModel(
table_view=table,
table_headers=headers,
editable_headers=self._data.header,
editable_headers=editable_headers,
delegates={
# "time": self._delegate_time,
},
@ -147,8 +152,9 @@ class EditLateralContributionAdisTSWindow(PamhyrWindow):
self.plot.draw()
def setup_connections(self):
self.find(QAction, "action_add").triggered.connect(self.add)
self.find(QAction, "action_del").triggered.connect(self.delete)
if self._study.is_editable():
self.find(QAction, "action_add").triggered.connect(self.add)
self.find(QAction, "action_del").triggered.connect(self.delete)
self._table.dataChanged.connect(self.update)

View File

@ -92,9 +92,13 @@ class LateralContributionAdisTSWindow(PamhyrWindow):
def setup_table(self):
self._table = {}
self._delegate_rk = []
if self._study.is_editable():
editable_headers = self._trad.get_dict("table_headers")
else:
editable_headers = []
delegate_rk = ComboBoxDelegate(
data=None,
mode="rk",
@ -114,7 +118,7 @@ class LateralContributionAdisTSWindow(PamhyrWindow):
self._table = TableModel(
table_view=table,
table_headers=self._trad.get_dict("table_headers"),
editable_headers=self._trad.get_dict("table_headers"),
editable_headers=editable_headers,
delegates={
"reach": self._delegate_reach,
"begin_rk": delegate_rk,
@ -146,8 +150,10 @@ class LateralContributionAdisTSWindow(PamhyrWindow):
)
def setup_connections(self):
self.find(QAction, "action_add").triggered.connect(self.add)
self.find(QAction, "action_del").triggered.connect(self.delete)
if self._study.is_editable():
self.find(QAction, "action_add").triggered.connect(self.add)
self.find(QAction, "action_del").triggered.connect(self.delete)
self.find(QAction, "action_edit").triggered.connect(self.edit)
table = self.find(QTableView, f"tableView")

View File

@ -965,7 +965,8 @@ class GraphWidget(QGraphicsView):
if self.selected_new_edge_src_node() is None:
self.set_selected_new_edge_src_node(nodes[0])
else:
self.add_edge(self.selected_new_edge_src_node(), nodes[0])
self.add_edge(self.selected_new_edge_src_node(),
nodes[0])
# Delete nodes and edges
elif self._state == "del":

View File

@ -76,14 +76,18 @@ class EditPolluantWindow(PamhyrWindow):
self.setup_table()
def setup_table(self):
headers = {}
table_headers = self._trad.get_dict("table_headers")
if self._study.is_editable():
editable_headers = self._trad.get_dict("table_headers")
else:
editable_headers = []
table = self.find(QTableView, "tableView")
self._table = TableModel(
table_view=table,
table_headers=table_headers,
editable_headers=table_headers,
editable_headers=editable_headers,
delegates={},
data=self._data,
undo=self._undo_stack,

View File

@ -54,10 +54,10 @@ class SetEnabledCommand(QUndoCommand):
self._new = enabled
def undo(self):
self._pollutants_lst.get(self._index).enabled = self._old
self._pollutants_lst[self._index].enabled = self._old
def redo(self):
self._pollutants_lst.get(self._index).enabled = self._new
self._pollutants_lst[self._index].enabled = self._new
class AddCommand(QUndoCommand):

View File

@ -78,11 +78,16 @@ class PollutantsWindow(PamhyrWindow):
def setup_table(self):
self._table = None
if self._study.is_editable():
editable_headers = self._trad.get_dict("table_headers")
else:
editable_headers = []
table = self.find(QTableView, f"tableView")
self._table = TableModel(
table_view=table,
table_headers=self._trad.get_dict("table_headers"),
editable_headers=["name"],
editable_headers=editable_headers,
trad=self._trad,
data=self._study.river,
undo=self._undo_stack,
@ -104,8 +109,10 @@ class PollutantsWindow(PamhyrWindow):
self._set_checkbox_state()
def setup_connections(self):
self.find(QAction, "action_add").triggered.connect(self.add)
self.find(QAction, "action_delete").triggered.connect(self.delete)
if self._study.is_editable():
self.find(QAction, "action_add").triggered.connect(self.add)
self.find(QAction, "action_delete").triggered.connect(self.delete)
self.find(QAction, "action_edit").triggered.connect(self.edit)
self.find(QAction, "action_initial_conditions"
).triggered.connect(self.initial_conditions)