SL: Add read only support.

scenarios
Pierre-Antoine Rouby 2024-09-06 10:22:38 +02:00
parent 3de96a8d9d
commit d0e70ddddc
9 changed files with 82 additions and 39 deletions

View File

@ -207,6 +207,8 @@ class EditBoundaryConditionWindow(PamhyrWindow):
if self._study.is_editable():
self._d50sigma.d50Changed.connect(self.d50_changed)
self._d50sigma.sigmaChanged.connect(self.sigma_changed)
else:
self._d50sigma.setEnabled(False)
def d50_changed(self, value):
self._undo_stack.push(

View File

@ -89,8 +89,6 @@ class BoundaryConditionWindow(PamhyrWindow):
self.setup_graph()
self.setup_connections()
self.ui.setWindowTitle(self._title)
def setup_table(self):
self._table = {}

View File

@ -113,11 +113,16 @@ class InitialConditionsWindow(PamhyrWindow):
parent=self
)
if self._study.is_editable():
editable_headers = ["rk", "discharge", "elevation", "height"]
else:
editable_headers = []
self._table = InitialConditionTableModel(
reach=self._reach,
table_view=table,
table_headers=self._trad.get_dict("table_headers"),
editable_headers=["rk", "discharge", "elevation", "height"],
editable_headers=editable_headers,
delegates={"rk": self._delegate_rk},
data=self._study,
undo=self._undo_stack,
@ -167,19 +172,20 @@ class InitialConditionsWindow(PamhyrWindow):
self.plot_2.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)
self.find(QAction, "action_import").triggered\
.connect(self.import_from_file)
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.find(QAction, "action_import").triggered\
.connect(self.import_from_file)
self.find(QPushButton, "pushButton_generate_1").clicked.connect(
self.generate_growing_constante_height
)
self.find(QPushButton, "pushButton_generate_1").clicked.connect(
self.generate_growing_constante_height
)
self.find(QPushButton, "pushButton_generate_2").clicked.connect(
self.generate_discharge
)
self.find(QPushButton, "pushButton_generate_2").clicked.connect(
self.generate_discharge
)
self._table.dataChanged.connect(self._update_plot)

View File

@ -88,11 +88,16 @@ class EditReservoirWindow(PamhyrWindow):
headers = {}
table_headers = self._trad.get_dict("table_headers")
if self._study.is_editable():
editable_headers = 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,
@ -123,9 +128,10 @@ class EditReservoirWindow(PamhyrWindow):
self.plot.draw()
def setup_connections(self):
self.find(QAction, "action_add").triggered.connect(self.add)
self.find(QAction, "action_delete").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_delete").triggered.connect(self.delete)
self.find(QAction, "action_sort").triggered.connect(self.sort)
self._table.dataChanged.connect(self.update)

View File

@ -83,11 +83,16 @@ class ReservoirWindow(PamhyrWindow):
parent=self
)
if self._study.is_editable():
editable_headers = ["name", "node"]
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", "node"],
editable_headers=editable_headers,
delegates={
"node": self._delegate_node,
},
@ -107,8 +112,10 @@ class ReservoirWindow(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_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)
def index_selected_row(self):

View File

@ -83,11 +83,17 @@ class EditSedimentLayersWindow(PamhyrWindow):
def setup_table(self):
table_headers = self._trad.get_dict("table_headers")
if self._study.is_editable():
editable_headers = list(table_headers)
else:
editable_headers = []
table = self.find(QTableView, f"tableView")
self._table = TableModel(
table_view=table,
table_headers=table_headers,
editable_headers=list(table_headers),
editable_headers=editable_headers,
data=self._sl,
trad=self._trad,
undo=self._undo_stack,
@ -118,11 +124,12 @@ class EditSedimentLayersWindow(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_move_up").triggered.connect(self.move_up)
self.find(QAction, "action_move_down").triggered.connect(
self.move_down)
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_move_up").triggered.connect(self.move_up)
self.find(QAction, "action_move_down")\
.triggered.connect(self.move_down)
self._table.dataChanged.connect(self._set_plot)
self._table.layoutChanged.connect(self._set_plot)

View File

@ -80,8 +80,6 @@ class ProfileSedimentLayersWindow(PamhyrWindow):
self.setup_graph()
self.setup_connections()
self.ui.setWindowTitle(self._title)
def compute_name(self, study, trad):
rname = self._reach.name
if rname == "":
@ -91,8 +89,9 @@ class ProfileSedimentLayersWindow(PamhyrWindow):
if pname == "":
pname = _translate(
"SedimentLayers",
"(no name - @rk)").replace("@rk", str(self._profile.rk)
)
"(no name - @rk)").replace(
"@rk", str(self._profile.rk)
)
return (
trad[self._pamhyr_name] + " - "
@ -108,13 +107,18 @@ class ProfileSedimentLayersWindow(PamhyrWindow):
parent=self
)
if self._study.is_editable():
editable_headers = ["sl"]
else:
editable_headers = []
table = self.find(QTableView, f"tableView")
self._table = TableModel(
table_view=table,
data=self._profile,
opt_data=self._study,
table_headers=table_headers,
editable_headers=["sl"],
editable_headers=editable_headers,
delegates={"sl": self._delegate_sl},
trad=self._trad,
undo=self._undo_stack,

View File

@ -100,13 +100,18 @@ class ReachSedimentLayersWindow(PamhyrWindow):
parent=self
)
if self._study.is_editable():
editable_headers = ["sl"]
else:
editable_headers = []
table = self.find(QTableView, f"tableView")
self._table = TableModel(
table_view=table,
data=self._reach,
opt_data=self._study,
table_headers=table_headers,
editable_headers=["sl"],
editable_headers=editable_headers,
delegates={"sl": self._delegate_sl},
trad=self._trad,
undo=self._undo_stack,
@ -143,9 +148,10 @@ class ReachSedimentLayersWindow(PamhyrWindow):
self.find(QPushButton, "pushButton_edit")\
.clicked\
.connect(self.edit_sl)
self.find(QPushButton, "pushButton_apply")\
.clicked\
.connect(self.apply_sl_each_profile)
if self._study.is_editable():
self.find(QPushButton, "pushButton_apply")\
.clicked.connect(self.apply_sl_each_profile)
self._table.layoutChanged\
.connect(self._update_plot)

View File

@ -77,11 +77,16 @@ class SedimentLayersWindow(PamhyrWindow):
self.setup_connections()
def setup_table(self):
if self._study.is_editable():
editable_headers = ["name", "comment"]
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", "comment"],
editable_headers=editable_headers,
data=self._study.river.sediment_layers,
trad=self._trad,
undo=self._undo_stack,
@ -98,8 +103,10 @@ class SedimentLayersWindow(PamhyrWindow):
self.plot_layout.addWidget(self.canvas)
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_sediment_layers)