mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
No commits in common. "3dfbdc328ec745272aa6037f7c0b9a9c7fed81ca" and "78ba7b70b46dcd3c19048a198ff5791a6118d480" have entirely different histories.
3dfbdc328e
...
78ba7b70b4
|
|
@ -104,12 +104,6 @@ class PollutantCharacteristics(SQLSubModel):
|
||||||
self._ac = value
|
self._ac = value
|
||||||
elif key == 8:
|
elif key == 8:
|
||||||
self._bc = value
|
self._bc = value
|
||||||
self.propagate_modified()
|
|
||||||
|
|
||||||
def propagate_modified(self):
|
|
||||||
self.modified()
|
|
||||||
if hasattr(self, "_pollutant") and self._pollutant:
|
|
||||||
self._pollutant.modified()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_create(cls, execute, ext=""):
|
def _db_create(cls, execute, ext=""):
|
||||||
|
|
@ -262,12 +256,6 @@ class PollutantCharacteristics(SQLSubModel):
|
||||||
if not self.must_be_saved():
|
if not self.must_be_saved():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
execute(
|
|
||||||
"DELETE FROM pollutants_characteristics " +
|
|
||||||
f"WHERE pamhyr_id = {self.id} " +
|
|
||||||
f"AND scenario = {self._status.scenario_id}"
|
|
||||||
)
|
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"pollutants_characteristics(pamhyr_id, deleted, " +
|
"pollutants_characteristics(pamhyr_id, deleted, " +
|
||||||
|
|
@ -324,7 +312,7 @@ class Pollutants(SQLSubModel):
|
||||||
@name.setter
|
@name.setter
|
||||||
def name(self, name):
|
def name(self, name):
|
||||||
self._name = name
|
self._name = name
|
||||||
self.modified()
|
self._status.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def data(self):
|
def data(self):
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
||||||
from Model.Except import NotImplementedMethodeError
|
from Model.Except import NotImplementedMethodeError
|
||||||
from Model.Tools.PamhyrListExt import PamhyrModelList
|
from Model.Tools.PamhyrList import PamhyrModelList
|
||||||
from Model.Pollutants.Pollutants import Pollutants
|
from Model.Pollutants.Pollutants import Pollutants
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,12 +89,6 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||||
|
|
||||||
def setup_table(self):
|
def setup_table(self):
|
||||||
table_headers = self._trad.get_dict("table_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 = []
|
|
||||||
|
|
||||||
if self._data.type == "Concentration":
|
if self._data.type == "Concentration":
|
||||||
self._data.header = ["time", "concentration"]
|
self._data.header = ["time", "concentration"]
|
||||||
else:
|
else:
|
||||||
|
|
@ -114,7 +108,7 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||||
self._table = TableModel(
|
self._table = TableModel(
|
||||||
table_view=table,
|
table_view=table,
|
||||||
table_headers=headers,
|
table_headers=headers,
|
||||||
editable_headers=editable_headers,
|
editable_headers=self._data.header,
|
||||||
delegates={
|
delegates={
|
||||||
# "time": self._delegate_time,
|
# "time": self._delegate_time,
|
||||||
},
|
},
|
||||||
|
|
@ -147,10 +141,9 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||||
self.plot.draw()
|
self.plot.draw()
|
||||||
|
|
||||||
def setup_connections(self):
|
def setup_connections(self):
|
||||||
if self._study.is_editable():
|
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
||||||
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
|
||||||
self._table.dataChanged.connect(self.update)
|
self._table.dataChanged.connect(self.update)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
|
|
||||||
|
|
@ -106,16 +106,11 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
|
||||||
parent=self
|
parent=self
|
||||||
)
|
)
|
||||||
|
|
||||||
if self._study.is_editable():
|
|
||||||
editable_headers = self._trad.get_dict("table_headers")
|
|
||||||
else:
|
|
||||||
editable_headers = []
|
|
||||||
|
|
||||||
table = self.find(QTableView, f"tableView")
|
table = self.find(QTableView, f"tableView")
|
||||||
self._table = TableModel(
|
self._table = TableModel(
|
||||||
table_view=table,
|
table_view=table,
|
||||||
table_headers=self._trad.get_dict("table_headers"),
|
table_headers=self._trad.get_dict("table_headers"),
|
||||||
editable_headers=editable_headers,
|
editable_headers=["type", "node", "pol"],
|
||||||
delegates={
|
delegates={
|
||||||
"type": self._delegate_type,
|
"type": self._delegate_type,
|
||||||
"node": self._delegate_node,
|
"node": self._delegate_node,
|
||||||
|
|
@ -142,10 +137,8 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
|
||||||
self.graph_layout.addWidget(self.graph_widget)
|
self.graph_layout.addWidget(self.graph_widget)
|
||||||
|
|
||||||
def setup_connections(self):
|
def setup_connections(self):
|
||||||
if self._study.is_editable():
|
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
|
||||||
|
|
||||||
self.find(QAction, "action_edit").triggered.connect(self.edit)
|
self.find(QAction, "action_edit").triggered.connect(self.edit)
|
||||||
|
|
||||||
def index_selected_row(self):
|
def index_selected_row(self):
|
||||||
|
|
|
||||||
|
|
@ -99,17 +99,12 @@ class D90AdisTSWindow(PamhyrWindow):
|
||||||
|
|
||||||
path_icons = os.path.join(self._get_ui_directory(), f"ressources")
|
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")
|
table_default = self.find(QTableView, f"tableView")
|
||||||
|
|
||||||
self._table = D90TableDefaultModel(
|
self._table = D90TableDefaultModel(
|
||||||
table_view=table_default,
|
table_view=table_default,
|
||||||
table_headers=self._trad.get_dict("table_headers"),
|
table_headers=self._trad.get_dict("table_headers"),
|
||||||
editable_headers=editable_headers,
|
editable_headers=["name", "d90"],
|
||||||
delegates={},
|
delegates={},
|
||||||
data=self._data,
|
data=self._data,
|
||||||
undo=self._undo_stack,
|
undo=self._undo_stack,
|
||||||
|
|
@ -129,15 +124,10 @@ class D90AdisTSWindow(PamhyrWindow):
|
||||||
|
|
||||||
action_add = QAction(self)
|
action_add = QAction(self)
|
||||||
action_add.setIcon(QIcon(os.path.join(path_icons, f"add.png")))
|
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 = QAction(self)
|
||||||
action_delete.setIcon(QIcon(os.path.join(path_icons, f"del.png")))
|
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_add)
|
||||||
toolBar.addAction(action_delete)
|
toolBar.addAction(action_delete)
|
||||||
|
|
@ -160,15 +150,10 @@ class D90AdisTSWindow(PamhyrWindow):
|
||||||
mode="rk"
|
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(
|
self._table_spec = D90TableModel(
|
||||||
table_view=self.table_spec,
|
table_view=self.table_spec,
|
||||||
table_headers=self._trad.get_dict("table_headers_spec"),
|
table_headers=self._trad.get_dict("table_headers_spec"),
|
||||||
editable_headers=editable_headers_spec,
|
editable_headers=["name", "reach", "start_rk", "end_rk", "d90"],
|
||||||
delegates={
|
delegates={
|
||||||
"reach": self._delegate_reach,
|
"reach": self._delegate_reach,
|
||||||
"start_rk": self._delegate_rk,
|
"start_rk": self._delegate_rk,
|
||||||
|
|
|
||||||
|
|
@ -99,11 +99,6 @@ class DIFAdisTSWindow(PamhyrWindow):
|
||||||
|
|
||||||
table_default = self.find(QTableView, f"tableView")
|
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(
|
self._delegate_method = ComboBoxDelegate(
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
data=self._study.river,
|
data=self._study.river,
|
||||||
|
|
@ -115,7 +110,7 @@ class DIFAdisTSWindow(PamhyrWindow):
|
||||||
self._table = DIFTableDefaultModel(
|
self._table = DIFTableDefaultModel(
|
||||||
table_view=table_default,
|
table_view=table_default,
|
||||||
table_headers=self._trad.get_dict("table_headers"),
|
table_headers=self._trad.get_dict("table_headers"),
|
||||||
editable_headers=editable_headers,
|
editable_headers=["method", "dif", "b", "c"],
|
||||||
delegates={
|
delegates={
|
||||||
"method": self._delegate_method
|
"method": self._delegate_method
|
||||||
},
|
},
|
||||||
|
|
@ -137,14 +132,10 @@ class DIFAdisTSWindow(PamhyrWindow):
|
||||||
|
|
||||||
action_add = QAction(self)
|
action_add = QAction(self)
|
||||||
action_add.setIcon(QIcon(os.path.join(path_icons, f"add.png")))
|
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 = QAction(self)
|
||||||
action_delete.setIcon(QIcon(os.path.join(path_icons, f"del.png")))
|
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_add)
|
||||||
toolBar.addAction(action_delete)
|
toolBar.addAction(action_delete)
|
||||||
|
|
@ -167,15 +158,11 @@ class DIFAdisTSWindow(PamhyrWindow):
|
||||||
mode="rk"
|
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(
|
self._table_spec = DIFTableModel(
|
||||||
table_view=self.table_spec,
|
table_view=self.table_spec,
|
||||||
table_headers=self._trad.get_dict("table_headers_spec"),
|
table_headers=self._trad.get_dict("table_headers_spec"),
|
||||||
editable_headers=editable_headers_spec,
|
editable_headers=["method", "reach", "start_rk",
|
||||||
|
"end_rk", "dif", "b", "c"],
|
||||||
delegates={
|
delegates={
|
||||||
"method": self._delegate_method,
|
"method": self._delegate_method,
|
||||||
"reach": self._delegate_reach,
|
"reach": self._delegate_reach,
|
||||||
|
|
|
||||||
|
|
@ -136,18 +136,13 @@ class PlotRKC(PamhyrPlot):
|
||||||
hs_color = []
|
hs_color = []
|
||||||
index = self.parent.tableView.selectedIndexes()
|
index = self.parent.tableView.selectedIndexes()
|
||||||
for i, hs in enumerate(lhs):
|
for i, hs in enumerate(lhs):
|
||||||
section = hs.input_section
|
|
||||||
if section is None:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if i == index[0].row():
|
if i == index[0].row():
|
||||||
color = "blue"
|
hs_color.append("blue")
|
||||||
elif hs.enabled:
|
elif hs.enabled:
|
||||||
color = "red"
|
hs_color.append("red")
|
||||||
else:
|
else:
|
||||||
color = "darkgrey"
|
hs_color.append("darkgrey")
|
||||||
|
x = hs.input_section.rk
|
||||||
x = section.rk
|
|
||||||
if x is not None:
|
if x is not None:
|
||||||
a = self.canvas.axes.annotate(
|
a = self.canvas.axes.annotate(
|
||||||
" > " + hs.name,
|
" > " + hs.name,
|
||||||
|
|
@ -156,13 +151,12 @@ class PlotRKC(PamhyrPlot):
|
||||||
verticalalignment='top',
|
verticalalignment='top',
|
||||||
annotation_clip=True,
|
annotation_clip=True,
|
||||||
fontsize=9,
|
fontsize=9,
|
||||||
color=color,
|
color=hs_color[-1],
|
||||||
)
|
)
|
||||||
self.anotate_lst.append(a)
|
self.anotate_lst.append(a)
|
||||||
vx.append(x)
|
vx.append(x)
|
||||||
vymin.append(min(z_min))
|
vymin.append(min(z_min))
|
||||||
vymax.append(max(z_max))
|
vymax.append(max(z_max))
|
||||||
hs_color.append(color)
|
|
||||||
|
|
||||||
self.hs_vlines = self.canvas.axes.vlines(
|
self.hs_vlines = self.canvas.axes.vlines(
|
||||||
x=vx, ymin=vymin, ymax=vymax,
|
x=vx, ymin=vymin, ymax=vymax,
|
||||||
|
|
|
||||||
|
|
@ -108,15 +108,10 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
|
||||||
|
|
||||||
table_default = self.find(QTableView, f"tableView")
|
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(
|
self._table = InitialConditionTableDefaultModel(
|
||||||
table_view=table_default,
|
table_view=table_default,
|
||||||
table_headers=self._trad.get_dict("table_headers"),
|
table_headers=self._trad.get_dict("table_headers"),
|
||||||
editable_headers=editable_headers,
|
editable_headers=["name", "concentration", "eg", "em", "ed"],
|
||||||
delegates={},
|
delegates={},
|
||||||
data=self._data,
|
data=self._data,
|
||||||
undo=self._undo_stack,
|
undo=self._undo_stack,
|
||||||
|
|
@ -136,14 +131,10 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
|
||||||
|
|
||||||
action_add = QAction(self)
|
action_add = QAction(self)
|
||||||
action_add.setIcon(QIcon(os.path.join(path_icons, f"add.png")))
|
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 = QAction(self)
|
||||||
action_delete.setIcon(QIcon(os.path.join(path_icons, f"del.png")))
|
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_add)
|
||||||
toolBar.addAction(action_delete)
|
toolBar.addAction(action_delete)
|
||||||
|
|
@ -166,15 +157,12 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
|
||||||
mode="rk"
|
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(
|
self._table_spec = InitialConditionTableModel(
|
||||||
table_view=self.table_spec,
|
table_view=self.table_spec,
|
||||||
table_headers=self._trad.get_dict("table_headers_spec"),
|
table_headers=self._trad.get_dict("table_headers_spec"),
|
||||||
editable_headers=editable_headers_spec,
|
editable_headers=["name", "reach", "start_rk",
|
||||||
|
"end_rk", "concentration",
|
||||||
|
"eg", "em", "ed", "rate"],
|
||||||
delegates={
|
delegates={
|
||||||
"reach": self._delegate_reach,
|
"reach": self._delegate_reach,
|
||||||
"start_rk": self._delegate_rk,
|
"start_rk": self._delegate_rk,
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ class ComboBoxDelegate(QItemDelegate):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
value = profiles[0].pamhyr_id if len(profiles) > 0 else None
|
value = profiles[0].rk if len(profiles) > 0 else None
|
||||||
else:
|
else:
|
||||||
value = text
|
value = text
|
||||||
|
|
||||||
|
|
@ -222,25 +222,15 @@ class TableModel(PamhyrTableModel):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif self._headers[column] == "begin_rk":
|
elif self._headers[column] == "begin_rk":
|
||||||
_edge = self._lst.get(self._tab, row).reach
|
|
||||||
_begin_rk = next(
|
|
||||||
p for p in _edge.reach.profiles
|
|
||||||
if p.pamhyr_id == value
|
|
||||||
)
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetBeginCommand(
|
SetBeginCommand(
|
||||||
self._lst, self._tab, row, _begin_rk
|
self._lst, self._tab, row, value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif self._headers[column] == "end_rk":
|
elif self._headers[column] == "end_rk":
|
||||||
_edge = self._lst.get(self._tab, row).reach
|
|
||||||
_end_rk = next(
|
|
||||||
p for p in _edge.reach.profiles
|
|
||||||
if p.pamhyr_id == value
|
|
||||||
)
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetEndCommand(
|
SetEndCommand(
|
||||||
self._lst, self._tab, row, _end_rk
|
self._lst, self._tab, row, value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
|
|
@ -103,11 +103,6 @@ class EditLateralContributionAdisTSWindow(PamhyrWindow):
|
||||||
parent=self
|
parent=self
|
||||||
)
|
)
|
||||||
|
|
||||||
if self._study.is_editable():
|
|
||||||
editable_headers = self._trad.get_dict("table_headers")
|
|
||||||
else:
|
|
||||||
editable_headers = []
|
|
||||||
|
|
||||||
headers = {}
|
headers = {}
|
||||||
table_headers = self._trad.get_dict("table_headers")
|
table_headers = self._trad.get_dict("table_headers")
|
||||||
for h in self._data.header:
|
for h in self._data.header:
|
||||||
|
|
@ -117,7 +112,7 @@ class EditLateralContributionAdisTSWindow(PamhyrWindow):
|
||||||
self._table = TableModel(
|
self._table = TableModel(
|
||||||
table_view=table,
|
table_view=table,
|
||||||
table_headers=headers,
|
table_headers=headers,
|
||||||
editable_headers=editable_headers,
|
editable_headers=self._data.header,
|
||||||
delegates={
|
delegates={
|
||||||
# "time": self._delegate_time,
|
# "time": self._delegate_time,
|
||||||
},
|
},
|
||||||
|
|
@ -152,9 +147,8 @@ class EditLateralContributionAdisTSWindow(PamhyrWindow):
|
||||||
self.plot.draw()
|
self.plot.draw()
|
||||||
|
|
||||||
def setup_connections(self):
|
def setup_connections(self):
|
||||||
if self._study.is_editable():
|
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
|
||||||
|
|
||||||
self._table.dataChanged.connect(self.update)
|
self._table.dataChanged.connect(self.update)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,12 +92,8 @@ class LateralContributionAdisTSWindow(PamhyrWindow):
|
||||||
|
|
||||||
def setup_table(self):
|
def setup_table(self):
|
||||||
self._table = {}
|
self._table = {}
|
||||||
self._delegate_rk = []
|
|
||||||
|
|
||||||
if self._study.is_editable():
|
self._delegate_rk = []
|
||||||
editable_headers = self._trad.get_dict("table_headers")
|
|
||||||
else:
|
|
||||||
editable_headers = []
|
|
||||||
|
|
||||||
delegate_rk = ComboBoxDelegate(
|
delegate_rk = ComboBoxDelegate(
|
||||||
data=None,
|
data=None,
|
||||||
|
|
@ -118,7 +114,7 @@ class LateralContributionAdisTSWindow(PamhyrWindow):
|
||||||
self._table = TableModel(
|
self._table = TableModel(
|
||||||
table_view=table,
|
table_view=table,
|
||||||
table_headers=self._trad.get_dict("table_headers"),
|
table_headers=self._trad.get_dict("table_headers"),
|
||||||
editable_headers=editable_headers,
|
editable_headers=self._trad.get_dict("table_headers"),
|
||||||
delegates={
|
delegates={
|
||||||
"reach": self._delegate_reach,
|
"reach": self._delegate_reach,
|
||||||
"begin_rk": delegate_rk,
|
"begin_rk": delegate_rk,
|
||||||
|
|
@ -150,10 +146,8 @@ class LateralContributionAdisTSWindow(PamhyrWindow):
|
||||||
)
|
)
|
||||||
|
|
||||||
def setup_connections(self):
|
def setup_connections(self):
|
||||||
if self._study.is_editable():
|
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
|
||||||
|
|
||||||
self.find(QAction, "action_edit").triggered.connect(self.edit)
|
self.find(QAction, "action_edit").triggered.connect(self.edit)
|
||||||
|
|
||||||
table = self.find(QTableView, f"tableView")
|
table = self.find(QTableView, f"tableView")
|
||||||
|
|
|
||||||
|
|
@ -965,8 +965,7 @@ class GraphWidget(QGraphicsView):
|
||||||
if self.selected_new_edge_src_node() is None:
|
if self.selected_new_edge_src_node() is None:
|
||||||
self.set_selected_new_edge_src_node(nodes[0])
|
self.set_selected_new_edge_src_node(nodes[0])
|
||||||
else:
|
else:
|
||||||
self.add_edge(self.selected_new_edge_src_node(),
|
self.add_edge(self.selected_new_edge_src_node(), nodes[0])
|
||||||
nodes[0])
|
|
||||||
|
|
||||||
# Delete nodes and edges
|
# Delete nodes and edges
|
||||||
elif self._state == "del":
|
elif self._state == "del":
|
||||||
|
|
|
||||||
|
|
@ -76,18 +76,14 @@ class EditPolluantWindow(PamhyrWindow):
|
||||||
self.setup_table()
|
self.setup_table()
|
||||||
|
|
||||||
def setup_table(self):
|
def setup_table(self):
|
||||||
|
headers = {}
|
||||||
table_headers = self._trad.get_dict("table_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")
|
table = self.find(QTableView, "tableView")
|
||||||
self._table = TableModel(
|
self._table = TableModel(
|
||||||
table_view=table,
|
table_view=table,
|
||||||
table_headers=table_headers,
|
table_headers=table_headers,
|
||||||
editable_headers=editable_headers,
|
editable_headers=table_headers,
|
||||||
delegates={},
|
delegates={},
|
||||||
data=self._data,
|
data=self._data,
|
||||||
undo=self._undo_stack,
|
undo=self._undo_stack,
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,7 @@ _translate = QCoreApplication.translate
|
||||||
|
|
||||||
class TableModel(PamhyrTableModel):
|
class TableModel(PamhyrTableModel):
|
||||||
def _setup_lst(self):
|
def _setup_lst(self):
|
||||||
self._lst = list(
|
self._lst = self._data._Pollutants
|
||||||
filter(
|
|
||||||
lambda dif: dif._deleted is False,
|
|
||||||
self._data._Pollutants._lst
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def rowCount(self, parent):
|
def rowCount(self, parent):
|
||||||
return len(self._lst)
|
return len(self._lst)
|
||||||
|
|
@ -66,7 +61,7 @@ class TableModel(PamhyrTableModel):
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
if self._headers[column] == "name":
|
if self._headers[column] == "name":
|
||||||
return self._lst[row].name
|
return self._lst.get(row).name
|
||||||
|
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
|
|
@ -96,36 +91,29 @@ class TableModel(PamhyrTableModel):
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
AddCommand(
|
AddCommand(
|
||||||
self._data._Pollutants, row, self._data.ic_adists
|
self._lst, row, self._data.ic_adists
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self._setup_lst()
|
|
||||||
self.endInsertRows()
|
self.endInsertRows()
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def delete(self, rows, parent=QModelIndex()):
|
def delete(self, rows, parent=QModelIndex()):
|
||||||
self.beginRemoveRows(parent, rows[0], rows[-1])
|
self.beginRemoveRows(parent, rows[0], rows[-1])
|
||||||
|
|
||||||
data_rows = {
|
|
||||||
id(pol): i for i, pol in enumerate(self._data._Pollutants._lst)
|
|
||||||
}
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
DelCommand(
|
DelCommand(
|
||||||
self._data._Pollutants,
|
self._lst, rows, self._data.ic_adists
|
||||||
[data_rows[id(self._lst[row])] for row in rows
|
|
||||||
if 0 <= row < len(self._lst)],
|
|
||||||
self._data.ic_adists
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self._setup_lst()
|
|
||||||
self.endRemoveRows()
|
self.endRemoveRows()
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def enabled(self, row, enabled, parent=QModelIndex()):
|
def enabled(self, row, enabled, parent=QModelIndex()):
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetEnabledCommand(
|
SetEnabledCommand(
|
||||||
self._data._Pollutants, row, enabled
|
self._lst, row, enabled
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
|
||||||
|
|
@ -34,14 +34,14 @@ class SetNameCommand(QUndoCommand):
|
||||||
|
|
||||||
self._pollutants_lst = pollutants_lst
|
self._pollutants_lst = pollutants_lst
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._pollutants_lst[self._index].name
|
self._old = self._pollutants_lst.get(self._index).name
|
||||||
self._new = str(new_value)
|
self._new = str(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._pollutants_lst[self._index].name = self._old
|
self._pollutants_lst.get(self._index).name = self._old
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._pollutants_lst[self._index].name = self._new
|
self._pollutants_lst.get(self._index).name = self._new
|
||||||
|
|
||||||
|
|
||||||
class SetEnabledCommand(QUndoCommand):
|
class SetEnabledCommand(QUndoCommand):
|
||||||
|
|
@ -54,10 +54,10 @@ class SetEnabledCommand(QUndoCommand):
|
||||||
self._new = enabled
|
self._new = enabled
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._pollutants_lst[self._index].enabled = self._old
|
self._pollutants_lst.get(self._index).enabled = self._old
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._pollutants_lst[self._index].enabled = self._new
|
self._pollutants_lst.get(self._index).enabled = self._new
|
||||||
|
|
||||||
|
|
||||||
class AddCommand(QUndoCommand):
|
class AddCommand(QUndoCommand):
|
||||||
|
|
|
||||||
|
|
@ -78,16 +78,11 @@ class PollutantsWindow(PamhyrWindow):
|
||||||
def setup_table(self):
|
def setup_table(self):
|
||||||
self._table = None
|
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")
|
table = self.find(QTableView, f"tableView")
|
||||||
self._table = TableModel(
|
self._table = TableModel(
|
||||||
table_view=table,
|
table_view=table,
|
||||||
table_headers=self._trad.get_dict("table_headers"),
|
table_headers=self._trad.get_dict("table_headers"),
|
||||||
editable_headers=editable_headers,
|
editable_headers=["name"],
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
data=self._study.river,
|
data=self._study.river,
|
||||||
undo=self._undo_stack,
|
undo=self._undo_stack,
|
||||||
|
|
@ -109,10 +104,8 @@ class PollutantsWindow(PamhyrWindow):
|
||||||
self._set_checkbox_state()
|
self._set_checkbox_state()
|
||||||
|
|
||||||
def setup_connections(self):
|
def setup_connections(self):
|
||||||
if self._study.is_editable():
|
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
self.find(QAction, "action_delete").triggered.connect(self.delete)
|
||||||
self.find(QAction, "action_delete").triggered.connect(self.delete)
|
|
||||||
|
|
||||||
self.find(QAction, "action_edit").triggered.connect(self.edit)
|
self.find(QAction, "action_edit").triggered.connect(self.edit)
|
||||||
self.find(QAction, "action_initial_conditions"
|
self.find(QAction, "action_initial_conditions"
|
||||||
).triggered.connect(self.initial_conditions)
|
).triggered.connect(self.initial_conditions)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue