stab window D90 AdisTS (undo / redo / add / delete / save / load), all should work correctly

disable_edition_parent_scenario
Dylan Jeannin 2026-05-11 14:58:42 +02:00
parent e3de7e7100
commit 606b9919e3
2 changed files with 31 additions and 7 deletions

View File

@ -62,9 +62,12 @@ class ComboBoxDelegate(QItemDelegate):
if self._mode == "rk":
reach_id = self._d90_spec_lst[index.row()].reach
reach = next(filter(
lambda edge: edge.id == reach_id, self._data.edges()
))
reach = next(
filter(
lambda edge: edge.id == reach_id, self._data.edges()
),
None
)
if reach_id is not None:
val = list(
@ -116,6 +119,8 @@ class D90TableModel(PamhyrTableModel):
super(D90TableModel, self).__init__(data=data, **kwargs)
self._data = data
if self._undo is not None:
self._undo.indexChanged.connect(lambda _: self.update())
def _setup_lst(self):
self._lst = list(
@ -216,7 +221,8 @@ class D90TableModel(PamhyrTableModel):
DelCommand(
self._data,
self._data._data,
[data_rows[id(self._lst[row])] for row in rows]
[data_rows[id(self._lst[row])] for row in rows
if 0 <= row < len(self._lst)]
)
)
@ -226,8 +232,10 @@ class D90TableModel(PamhyrTableModel):
def undo(self):
self._undo.undo()
self._setup_lst()
self.layoutChanged.emit()
def redo(self):
self._undo.redo()
self._setup_lst()
self.layoutChanged.emit()

View File

@ -43,7 +43,7 @@ from PyQt5.QtWidgets import (
from Modules import Modules
from View.InitialConditionsAdisTS.UndoCommand import (
from View.D90AdisTS.UndoCommand import (
SetCommand,
)
@ -264,11 +264,27 @@ class D90AdisTSWindow(PamhyrWindow):
self._update()
def _undo(self):
self._table.undo()
undo_stack = self._undo_stack
if undo_stack is None or not undo_stack.canUndo():
return
if isinstance(undo_stack.command(undo_stack.index() - 1), SetCommand):
self._table.undo()
else:
self._table_spec.undo()
self._update()
def _redo(self):
self._table.redo()
undo_stack = self._undo_stack
if undo_stack is None or not undo_stack.canRedo():
return
if isinstance(undo_stack.command(undo_stack.index()), SetCommand):
self._table.redo()
else:
self._table_spec.redo()
self._update()
def add(self):