refactoring: refacto frictions & stricklers.

This commit is contained in:
Pierre-Antoine Rouby committed 2023-10-04 14:34:07 +02:00
1 parent b430cbb62b
commit 4ce597a2a0
7 files changed
+72 -104

No files matched your search

+19 -19
View File
@@ -47,15 +47,13 @@ from View.Frictions.Table import (
TableModel, ComboBoxDelegate
)
from View.Plot.MplCanvas import MplCanvas
from View.Tools.Plot.PamhyrCanvas import MplCanvas
from View.Geometry.PlotKPZ import PlotKPZ
from View.Frictions.PlotStricklers import PlotStricklers
from View.Frictions.translate import table_headers, retranslate
from View.Frictions.translate import FrictionsTranslate
from View.Stricklers.Window import StricklersWindow
_translate = QCoreApplication.translate
logger = logging.getLogger()
class FrictionsWindow(PamhyrWindow):
@@ -80,6 +78,7 @@ class FrictionsWindow(PamhyrWindow):
title = name,
study = study,
config = config,
trad = FrictionsTranslate(),
parent = parent
)
@@ -89,17 +88,8 @@ class FrictionsWindow(PamhyrWindow):
def setup_table(self):
retranslate()
self._table = {}
table = self.find(QTableView, f"tableView")
self._table = TableModel(
data = self._reach,
study = self._study,
undo = self._undo_stack,
)
table.setModel(self._table)
self._delegate_stricklers = ComboBoxDelegate(
data = self._reach,
study = self._study,
@@ -107,13 +97,23 @@ class FrictionsWindow(PamhyrWindow):
parent=self
)
table.setItemDelegateForColumn(
3, self._delegate_stricklers
table = self.find(QTableView, f"tableView")
self._table = TableModel(
table_view = table,
table_headers = self._trad.get_dict("table_headers"),
editable_headers = [
"name", "begin_kp", "end_kp",
"begin_strickler", "end_strickler"
],
delegates = {
"begin_strickler": self._delegate_stricklers,
"end_strickler": self._delegate_stricklers,
},
data = self._reach,
undo = self._undo_stack,
opt_data = self._study
)
table.setItemDelegateForColumn(
4, self._delegate_stricklers
)
table.setModel(self._table)
table.setSelectionBehavior(QAbstractItemView.SelectRows)
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
table.setAlternatingRowColors(True)