BC: Fix #13 paste undo command.

setup.py
Pierre-Antoine Rouby 2023-11-22 10:00:49 +01:00
parent 9fe1b35a59
commit 1a708921e3
5 changed files with 9 additions and 40 deletions

View File

@ -44,7 +44,6 @@ from Model.BoundaryCondition.BoundaryConditionTypes import (
from View.BoundaryCondition.Edit.UndoCommand import ( from View.BoundaryCondition.Edit.UndoCommand import (
SetDataCommand, AddCommand, DelCommand, SetDataCommand, AddCommand, DelCommand,
SortCommand, MoveCommand, PasteCommand, SortCommand, MoveCommand, PasteCommand,
DuplicateCommand,
) )
_translate = QCoreApplication.translate _translate = QCoreApplication.translate

View File

@ -174,25 +174,10 @@ class PasteCommand(QUndoCommand):
self._bcs.reverse() self._bcs.reverse()
def undo(self): def undo(self):
self._data.delete(self._bcs) self._data.delete_i(
range(self._row, self._row + len(self._bcs))
)
def redo(self): def redo(self):
for bc in self._bcs: for bc in self._bcs:
self._data.insert(self._row, bc) self._data.insert(self._row, bc)
class DuplicateCommand(QUndoCommand):
def __init__(self, data, rows, bc):
QUndoCommand.__init__(self)
self._data = data
self._rows = rows
self._bc = deepcopy(bc)
self._bc.reverse()
def undo(self):
self._data.delete(self._bc)
def redo(self):
for bc in self._bcs:
self._data.insert(self._rows[0], bc)

View File

@ -44,7 +44,7 @@ from View.Tools.PamhyrTable import PamhyrTableModel
from View.BoundaryCondition.UndoCommand import ( from View.BoundaryCondition.UndoCommand import (
SetNameCommand, SetNodeCommand, SetTypeCommand, SetNameCommand, SetNodeCommand, SetTypeCommand,
AddCommand, DelCommand, SortCommand, AddCommand, DelCommand, SortCommand,
MoveCommand, PasteCommand, DuplicateCommand, MoveCommand, PasteCommand,
) )
from View.BoundaryCondition.translate import BC_types from View.BoundaryCondition.translate import BC_types

View File

@ -187,26 +187,11 @@ class PasteCommand(QUndoCommand):
self._bc.reverse() self._bc.reverse()
def undo(self): def undo(self):
self._bcs.delete(self._tab, self._bc) self._bcs.delete_i(
self._tab,
range(self._row, self._row + len(self._bc))
)
def redo(self): def redo(self):
for bc in self._bc: for bc in self._bc:
self._bcs.insert(self._tab, self._row, bc) self._bcs.insert(self._tab, self._row, bc)
class DuplicateCommand(QUndoCommand):
def __init__(self, bcs, tab, rows, bc):
QUndoCommand.__init__(self)
self._bcs = bcs
self._tab = tab
self._rows = rows
self._bc = deepcopy(bc)
self._bc.reverse()
def undo(self):
self._bcs.delete(self._tab, self._bc)
def redo(self):
for bc in self._bcs:
self._bcs.insert(self._tab, self._rows[0], bc)

View File

@ -47,7 +47,7 @@ from Model.BoundaryCondition.BoundaryConditionTypes import (
from View.BoundaryCondition.UndoCommand import ( from View.BoundaryCondition.UndoCommand import (
SetNameCommand, SetNodeCommand, SetTypeCommand, SetNameCommand, SetNodeCommand, SetTypeCommand,
AddCommand, DelCommand, SortCommand, AddCommand, DelCommand, SortCommand,
MoveCommand, PasteCommand, DuplicateCommand, MoveCommand, PasteCommand,
) )
from View.BoundaryCondition.Table import ( from View.BoundaryCondition.Table import (