mirror of https://gitlab.com/pamhyr/pamhyr2
AdisTT: Managing tab of time series when it's disabled
parent
02be084faf
commit
965443a8f9
|
|
@ -53,6 +53,10 @@ class Scenario(SQLSubModel):
|
|||
"geometry_pointXYZ", "geometry_profileXYZ",
|
||||
"river_reach", "river_node",
|
||||
"geotiff", "reservoir", "reservoir_data",
|
||||
# Temperature
|
||||
"boundary_condition_temperature", "boundary_condition_data_temperature",
|
||||
"initial_conditions_temperature", "initial_conditions_temperature_spec",
|
||||
"weather_parameters", "weather_parameters_data",
|
||||
]
|
||||
|
||||
related_tables = tables_with_deleted_column + [
|
||||
|
|
|
|||
|
|
@ -441,9 +441,9 @@ class WeatherParameters(SQLSubModel):
|
|||
f"AND scenario = {self._status.scenario_id}"
|
||||
)
|
||||
|
||||
reach = -1
|
||||
begin_section = -1
|
||||
end_section = -1
|
||||
reach = None
|
||||
begin_section = None
|
||||
end_section = None
|
||||
|
||||
if self._reach is not None:
|
||||
reach = self._reach._pamhyr_id
|
||||
|
|
|
|||
|
|
@ -147,10 +147,15 @@ class WeatherParametersTableModel(PamhyrTableModel):
|
|||
self._lst = self._data.lst
|
||||
self._lst = list(filter(lambda wp: wp.type == self._type, self._lst))
|
||||
|
||||
def update_tab_spec(self, type="ND"):
|
||||
self._type = type
|
||||
self._setup_lst()
|
||||
self.layoutChanged.emit()
|
||||
def update_tab_spec(self, type="ND", enabled=True):
|
||||
if enabled:
|
||||
self._type = type
|
||||
self._setup_lst()
|
||||
self.layoutChanged.emit()
|
||||
else:
|
||||
self._type = "ND"
|
||||
self._lst = []
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def get(self, row):
|
||||
if row < 0 or row >= len(self._lst):
|
||||
|
|
|
|||
|
|
@ -95,6 +95,9 @@ class WeatherParametersWindow(PamhyrWindow):
|
|||
self._wp_acronyms = [
|
||||
"AT", "SH", "GR", "RWS", "GT", "GFR", "ALB", "SC", "CCF"
|
||||
]
|
||||
self.types_with_data = [
|
||||
"AT", "SH", "GR", "RWS", "GT", "GFR"
|
||||
]
|
||||
self.setup_table()
|
||||
self.setup_connections()
|
||||
|
||||
|
|
@ -106,24 +109,24 @@ class WeatherParametersWindow(PamhyrWindow):
|
|||
layout.addWidget(toolBar)
|
||||
|
||||
# Add buttons to the toolbar
|
||||
action_add = QAction(self)
|
||||
action_add.setIcon(QIcon(os.path.join(path_icons, f"add.png")))
|
||||
self.action_add = QAction(self)
|
||||
self.action_add.setIcon(QIcon(os.path.join(path_icons, f"add.png")))
|
||||
|
||||
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")))
|
||||
self.action_add.triggered.connect(self.add)
|
||||
self.action_delete = QAction(self)
|
||||
self.action_delete.setIcon(QIcon(os.path.join(path_icons, f"del.png")))
|
||||
|
||||
if self._study.is_editable():
|
||||
action_delete.triggered.connect(self.delete)
|
||||
self.action_delete.triggered.connect(self.delete)
|
||||
|
||||
action_edit = QAction(self)
|
||||
action_edit.setIcon(QIcon(os.path.join(path_icons, f"edit.png")))
|
||||
action_edit.triggered.connect(self.edit)
|
||||
self.action_edit = QAction(self)
|
||||
self.action_edit.setIcon(QIcon(os.path.join(path_icons, f"edit.png")))
|
||||
self.action_edit.triggered.connect(self.edit)
|
||||
|
||||
toolBar.addAction(action_add)
|
||||
toolBar.addAction(action_delete)
|
||||
toolBar.addAction(action_edit)
|
||||
toolBar.addAction(self.action_add)
|
||||
toolBar.addAction(self.action_delete)
|
||||
toolBar.addAction(self.action_edit)
|
||||
|
||||
layout.addWidget(self.table_spec_title)
|
||||
layout.addWidget(self.table_spec)
|
||||
|
|
@ -241,20 +244,33 @@ class WeatherParametersWindow(PamhyrWindow):
|
|||
return self._selected_default_row_index
|
||||
|
||||
self._selected_default_row_index = rows[0].row()
|
||||
self.update_table_spec_title()
|
||||
type_selected = self._wp_acronyms[self._selected_default_row_index]
|
||||
tab_enabled = type_selected in self.types_with_data
|
||||
self.enable_actions(tab_enabled)
|
||||
|
||||
self.update_table_spec_title(enabled=tab_enabled)
|
||||
|
||||
self._table_spec.update_tab_spec(
|
||||
type=self._wp_acronyms[
|
||||
self._selected_default_row_index
|
||||
]
|
||||
type=type_selected, enabled=tab_enabled
|
||||
)
|
||||
|
||||
return self._selected_default_row_index
|
||||
|
||||
def update_table_spec_title(self):
|
||||
row = self._selected_default_row_index
|
||||
if 0 <= row < len(self.weather_params):
|
||||
self.table_spec_title.setText(self.weather_params[row])
|
||||
def enable_actions(self, enabled):
|
||||
if hasattr(self, "action_add"):
|
||||
self.action_add.setEnabled(enabled)
|
||||
if hasattr(self, "action_delete"):
|
||||
self.action_delete.setEnabled(enabled)
|
||||
if hasattr(self, "action_edit"):
|
||||
self.action_edit.setEnabled(enabled)
|
||||
|
||||
def update_table_spec_title(self, enabled=True):
|
||||
if enabled:
|
||||
row = self._selected_default_row_index
|
||||
if 0 <= row < len(self.weather_params):
|
||||
self.table_spec_title.setText(self.weather_params[row])
|
||||
else:
|
||||
self.table_spec_title.setText("")
|
||||
|
||||
def index_selected_row(self):
|
||||
table = self.table_spec
|
||||
|
|
|
|||
Loading…
Reference in New Issue