Geometry: Add read only support.

scenarios
Pierre-Antoine Rouby 2024-09-03 15:55:06 +02:00
parent 8afa3d1e30
commit 5cc5628956
3 changed files with 47 additions and 27 deletions

View File

@ -82,13 +82,18 @@ class ProfileWindow(PamhyrWindow):
self.setup_connections()
def setup_table(self):
if self._study.is_read_only():
editable_headers=[]
else:
editable_headers=["name", "x", "y", "z"]
table_headers = self._trad.get_dict("table_headers")
table = self.find(QTableView, "tableView")
self._tablemodel = GeometryProfileTableModel(
table_view=table,
table_headers=table_headers,
editable_headers=["name", "x", "y", "z"],
editable_headers=editable_headers,
data=self._profile,
undo=self._undo_stack
)
@ -123,16 +128,19 @@ class ProfileWindow(PamhyrWindow):
self._tablemodel.blockSignals(False)
def setup_connections(self):
actions = {
"action_sort_asc": self.sort_X_ascending,
"action_sort_des": self.sort_X_descending,
"action_up": self.move_up,
"action_down": self.move_down,
"action_add": self.add,
"action_delete": self.delete,
"action_purge": self.purge,
"action_reverse": self.reverse,
}
if self._study.is_read_only():
actions = {}
else:
actions = {
"action_sort_asc": self.sort_X_ascending,
"action_sort_des": self.sort_X_descending,
"action_up": self.move_up,
"action_down": self.move_down,
"action_add": self.add,
"action_delete": self.delete,
"action_purge": self.purge,
"action_reverse": self.reverse,
}
for action in actions:
self.find(QAction, action)\

View File

@ -99,13 +99,18 @@ class GeometryWindow(PamhyrWindow):
self.setup_connections()
def setup_table(self):
if self._study.is_read_only():
editable_headers = []
else:
editable_headers = ["name", "rk"]
table_headers = self._trad.get_dict("table_headers")
table = self.find(QTableView, "tableView")
self._table = GeometryReachTableModel(
table_view=table,
table_headers=table_headers,
editable_headers=["name", "rk"],
editable_headers=editable_headers,
data=self._reach,
undo=self._undo_stack
)
@ -181,20 +186,26 @@ class GeometryWindow(PamhyrWindow):
self._status_label.setText(txt)
def setup_connections(self):
actions = {
"action_import": self.import_from_file,
"action_export": self.export_to_file,
"action_sort_asc": self.sort_ascending,
"action_sort_des": self.sort_descending,
"action_up": self.move_up,
"action_down": self.move_down,
"action_add": self.add,
"action_delete": self.delete,
"action_edit": self.edit_profile,
"action_meshing": self.edit_meshing,
"action_update_rk": self.update_rk,
"action_purge": self.purge,
}
if self._study.is_read_only():
actions = {
"action_export": self.export_to_file,
"action_edit": self.edit_profile,
}
else:
actions = {
"action_import": self.import_from_file,
"action_export": self.export_to_file,
"action_sort_asc": self.sort_ascending,
"action_sort_des": self.sort_descending,
"action_up": self.move_up,
"action_down": self.move_down,
"action_add": self.add,
"action_delete": self.delete,
"action_edit": self.edit_profile,
"action_meshing": self.edit_meshing,
"action_update_rk": self.update_rk,
"action_purge": self.purge,
}
for action in actions:
self.find(QAction, action)\
@ -275,6 +286,7 @@ class GeometryWindow(PamhyrWindow):
win = ProfileWindow(
profile=profile,
study=self._study,
parent=self,
)
self._profile_window.append(win)

View File

@ -85,7 +85,7 @@ class NetworkWindow(PamhyrWindow):
def setup_table(self):
# Nodes table
if self._study.is_read_only:
if self._study.is_read_only():
node_editable_headers = []
edge_editable_headers = []
else: