mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
BC AdisTS Complete
This commit is contained in:
1 parent
b927aa81b3
commit
704130966e
13 files changed
+198
-478
No files matched your search
@@ -56,7 +56,6 @@ class SetTypeCommand(QUndoCommand):
|
||||
|
||||
def redo(self):
|
||||
self._bcs[self._index].type = self._new
|
||||
print("type : ", self._old, self._new, self._bcs[self._index].type)
|
||||
|
||||
class AddCommand(QUndoCommand):
|
||||
def __init__(self, pollutant, bcs_list, bcs, index):
|
||||
@@ -74,106 +73,27 @@ class AddCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
if self._new is None:
|
||||
self._new = self._bc_list.new(self._index, self._pollutant)
|
||||
print(self._new.pollutant)
|
||||
print(len(self._bc_list))
|
||||
print(len(self._bcs))
|
||||
else:
|
||||
self._bcs.insert(self._index, self._new)
|
||||
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
def __init__(self, bcs, tab, rows):
|
||||
def __init__(self, bcs, rows):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._bcs = bcs
|
||||
self._tab = tab
|
||||
self._rows = rows
|
||||
|
||||
self._bc = []
|
||||
for row in rows:
|
||||
self._bc.append((row, self._bcs.get(self._tab, row)))
|
||||
self._bc.append((row, self._bcs[row]))
|
||||
self._bc.sort()
|
||||
|
||||
def undo(self):
|
||||
for row, el in self._bc:
|
||||
self._bcs.insert(self._tab, row, el)
|
||||
self._bcs.insert(row, el)
|
||||
|
||||
def redo(self):
|
||||
self._bcs.delete_i(self._tab, self._rows)
|
||||
for row in self._rows:
|
||||
del self._bcs[row]
|
||||
|
||||
|
||||
class SortCommand(QUndoCommand):
|
||||
def __init__(self, bcs, tab, _reverse):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._bcs = bcs
|
||||
self._tab = tab
|
||||
self._reverse = _reverse
|
||||
|
||||
self._old = self._bcs.get_tab(self._tab)
|
||||
self._indexes = None
|
||||
|
||||
def undo(self):
|
||||
ll = self._bcs.get_tab(self._tab)
|
||||
self._bcs.sort(
|
||||
self._tab,
|
||||
key=lambda x: self._indexes[ll.index(x)]
|
||||
)
|
||||
|
||||
def redo(self):
|
||||
self._bcs.sort(
|
||||
self._tab,
|
||||
reverse=self._reverse,
|
||||
key=lambda x: x.name
|
||||
)
|
||||
if self._indexes is None:
|
||||
self._indexes = list(
|
||||
map(
|
||||
lambda p: self._old.index(p),
|
||||
self._bcs.get_tab(self._tab)
|
||||
)
|
||||
)
|
||||
self._old = None
|
||||
|
||||
|
||||
class MoveCommand(QUndoCommand):
|
||||
def __init__(self, bcs, tab, up, i):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._bcs = bcs
|
||||
self._tab = tab
|
||||
self._up = up == "up"
|
||||
self._i = i
|
||||
|
||||
def undo(self):
|
||||
if self._up:
|
||||
self._bcs.move_up(self._tab, self._i)
|
||||
else:
|
||||
self._bcs.move_down(self._tab, self._i)
|
||||
|
||||
def redo(self):
|
||||
if self._up:
|
||||
self._bcs.move_up(self._tab, self._i)
|
||||
else:
|
||||
self._bcs.move_down(self._tab, self._i)
|
||||
|
||||
|
||||
class PasteCommand(QUndoCommand):
|
||||
def __init__(self, bcs, tab, row, bc):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._bcs = bcs
|
||||
self._tab = tab
|
||||
self._row = row
|
||||
self._bc = deepcopy(bc)
|
||||
self._bc.reverse()
|
||||
|
||||
def undo(self):
|
||||
self._bcs.delete_i(
|
||||
self._tab,
|
||||
range(self._row, self._row + len(self._bc))
|
||||
)
|
||||
|
||||
def redo(self):
|
||||
for bc in self._bc:
|
||||
self._bcs.insert(self._tab, self._row, bc)
|
||||
Reference in new issue
Block a user