INI SPEC Table

This commit is contained in:
Youcef AOUAD committed 2024-06-12 15:06:28 +02:00
1 parent 35cc348f03
commit cd68bebf03
4 files changed
+146 -22

No files matched your search

+26 -10
View File
@@ -35,10 +35,8 @@ from PyQt5.QtWidgets import (
from View.Tools.PamhyrTable import PamhyrTableModel
from View.InitialConditions.UndoCommand import (
SetCommand, AddCommand, DelCommand,
SortCommand, MoveCommand, InsertCommand,
DuplicateCommand, GenerateCommand,
from View.InitialConditionsAdisTS.UndoCommand import (
SetCommand, AddCommand, SetCommandSpec,
)
logger = logging.getLogger()
@@ -62,6 +60,8 @@ class ComboBoxDelegate(QItemDelegate):
if self._mode == "kp":
reach_id = self._ic_spec_lst[index.row()].reach
print(self._data.edges()[0].id, reach_id)
reach = next(filter(lambda edge: edge.id == reach_id, self._data.edges()))
if reach_id is not None:
@@ -108,9 +108,17 @@ class ComboBoxDelegate(QItemDelegate):
class InitialConditionTableModel(PamhyrTableModel):
def __init__(self, data=None, **kwargs):
self._lst = data[0]._data
super(InitialConditionTableModel, self).__init__(**kwargs)
def __init__(self, river=None, data=None, **kwargs):
self._river = river
super(InitialConditionTableModel, self).__init__(data=data, **kwargs)
self._data = data
print("init table model : ", self._river)
def _setup_lst(self):
self._lst = self._data._data
def data(self, index, role):
if role != Qt.ItemDataRole.DisplayRole:
@@ -126,9 +134,10 @@ class InitialConditionTableModel(PamhyrTableModel):
return n
elif self._headers[column] is "reach":
n = self._lst[row].reach
print(n)
if n is None:
return self._trad['not_associated']
return next(filter(lambda edge: edge.id == n, self._data.edges())).name
return next(filter(lambda edge: edge.id == n, self._river.edges())).name
elif self._headers[column] is "start_kp":
n = self._lst[row].start_kp
if n is None:
@@ -175,12 +184,19 @@ class InitialConditionTableModel(PamhyrTableModel):
column = index.column()
try:
if self._headers[column] is not None:
if self._headers[column] != "reach":
self._undo.push(
SetCommand(
SetCommandSpec(
self._lst, row, self._headers[column], value
)
)
elif self._headers[column] == "reach":
print(self._river.edge(value).id)
self._undo.push(
SetCommandSpec(
self._lst, row, self._headers[column], self._river.edge(value).id
)
)
except Exception as e:
logger.info(e)
logger.debug(traceback.format_exc())