debug AdisTS BCs

This commit is contained in:
Theophile Terraz committed 2025-02-18 14:54:33 +01:00
1 parent e6aa840633
commit 8bac416ab5
17 files changed
+141 -73

No files matched your search

@@ -38,29 +38,14 @@ class SetDataCommand(QUndoCommand):
self._data = data
self._index = index
self._column = column
self._old = self._data._data[self._index][self._column]
_type = self._data._types[self._column]
self._new = _type(new_value)
self._old = self._data.get_i(self._index)[self._column]
self._new = new_value
def undo(self):
if self._column == 0:
self._data._data[self._index] = (
self._old, self._data._data[self._index][1]
)
else:
self._data._data[self._index] = (
self._data._data[self._index][0], self._old
)
self._data._set_i_c_v(self._index, self._column, self._old)
def redo(self):
if self._column == 0:
self._data._data[self._index] = (
self._new, self._data._data[self._index][1]
)
else:
self._data._data[self._index] = (
self._data._data[self._index][0], self._new
)
self._data._set_i_c_v(self._index, self._column, self._new)
class AddCommand(QUndoCommand):
@@ -76,11 +61,11 @@ class AddCommand(QUndoCommand):
def redo(self):
if self._new is None:
self._new = self._data._data.insert(self._index, (
self._new = self._data.insert(self._index, (
self._data._types[0](0), self._data._types[1](0.0)
))
else:
self._data._data.insert(self._index, self._new)
self._data.insert(self._index, self._new)
class DelCommand(QUndoCommand):
@@ -97,11 +82,10 @@ class DelCommand(QUndoCommand):
def undo(self):
for row, el in self._bc:
self._data._data.insert(row, el)
self._data.insert(row, el)
def redo(self):
for row in self._rows:
del self._data._data[row]
self._data.delete_i(self._rows)
class PasteCommand(QUndoCommand):
@@ -121,3 +105,34 @@ class PasteCommand(QUndoCommand):
def redo(self):
for bc in self._bcs:
self._data.insert(self._row, bc)
class SortCommand(QUndoCommand):
def __init__(self, data, _reverse):
QUndoCommand.__init__(self)
self._data = data
self._reverse = _reverse
self._old = self._data.data
self._indexes = None
def undo(self):
ll = self._data.data
self._data.sort(
key=lambda x: self._indexes[ll.index(x)]
)
def redo(self):
self._data.sort(
_reverse=self._reverse,
key=lambda x: x[0]
)
if self._indexes is None:
self._indexes = list(
map(
lambda p: self._old.index(p),
self._data.data
)
)
self._old = None