mirror of https://gitlab.com/pamhyr/pamhyr2
stab window D90 AdisTS (undo / redo / add / delete / save / load), all should work correctly
parent
e3de7e7100
commit
606b9919e3
|
|
@ -62,9 +62,12 @@ class ComboBoxDelegate(QItemDelegate):
|
||||||
if self._mode == "rk":
|
if self._mode == "rk":
|
||||||
reach_id = self._d90_spec_lst[index.row()].reach
|
reach_id = self._d90_spec_lst[index.row()].reach
|
||||||
|
|
||||||
reach = next(filter(
|
reach = next(
|
||||||
lambda edge: edge.id == reach_id, self._data.edges()
|
filter(
|
||||||
))
|
lambda edge: edge.id == reach_id, self._data.edges()
|
||||||
|
),
|
||||||
|
None
|
||||||
|
)
|
||||||
|
|
||||||
if reach_id is not None:
|
if reach_id is not None:
|
||||||
val = list(
|
val = list(
|
||||||
|
|
@ -116,6 +119,8 @@ class D90TableModel(PamhyrTableModel):
|
||||||
super(D90TableModel, self).__init__(data=data, **kwargs)
|
super(D90TableModel, self).__init__(data=data, **kwargs)
|
||||||
|
|
||||||
self._data = data
|
self._data = data
|
||||||
|
if self._undo is not None:
|
||||||
|
self._undo.indexChanged.connect(lambda _: self.update())
|
||||||
|
|
||||||
def _setup_lst(self):
|
def _setup_lst(self):
|
||||||
self._lst = list(
|
self._lst = list(
|
||||||
|
|
@ -216,7 +221,8 @@ class D90TableModel(PamhyrTableModel):
|
||||||
DelCommand(
|
DelCommand(
|
||||||
self._data,
|
self._data,
|
||||||
self._data._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):
|
def undo(self):
|
||||||
self._undo.undo()
|
self._undo.undo()
|
||||||
|
self._setup_lst()
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._undo.redo()
|
self._undo.redo()
|
||||||
|
self._setup_lst()
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ from PyQt5.QtWidgets import (
|
||||||
|
|
||||||
from Modules import Modules
|
from Modules import Modules
|
||||||
|
|
||||||
from View.InitialConditionsAdisTS.UndoCommand import (
|
from View.D90AdisTS.UndoCommand import (
|
||||||
SetCommand,
|
SetCommand,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -264,11 +264,27 @@ class D90AdisTSWindow(PamhyrWindow):
|
||||||
self._update()
|
self._update()
|
||||||
|
|
||||||
def _undo(self):
|
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()
|
self._update()
|
||||||
|
|
||||||
def _redo(self):
|
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()
|
self._update()
|
||||||
|
|
||||||
def add(self):
|
def add(self):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue