mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
IC: Implement copy/paste command.
This commit is contained in:
1 parent
c1f4aaf957
commit
459722610a
3 files changed
+85
-5
No files matched your search
@@ -197,7 +197,7 @@ class InitialConditionTableModel(PamhyrTableModel):
|
||||
self.endMoveRows()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def move_down(self, index, parent=QModelIndex()):
|
||||
def move_down(self, row, parent=QModelIndex()):
|
||||
if row > len(self._lst):
|
||||
return
|
||||
|
||||
@@ -214,6 +214,36 @@ class InitialConditionTableModel(PamhyrTableModel):
|
||||
self.endMoveRows()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def paste(self, index, header, data):
|
||||
if len(header) != 0:
|
||||
logger.error("Unexpected header in IC past data")
|
||||
return
|
||||
|
||||
if len(data) == 0:
|
||||
logger.error("Empty data")
|
||||
return
|
||||
|
||||
if len(data[0]) != 3:
|
||||
logger.error(f"Unexpected data size: [{data[0]}, ...]")
|
||||
return
|
||||
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
|
||||
self._undo.push(
|
||||
PasteCommand(
|
||||
self._lst, index,
|
||||
list(
|
||||
map(
|
||||
lambda d: self._lst.new_from_data(*d),
|
||||
data
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def undo(self):
|
||||
self._undo.undo()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
Reference in new issue
Block a user