AI'ed clipboard
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from PySide6.QtGui import QUndoCommand
|
||||
|
||||
from bedit_core.models import Component, ComponentID, Connection, ConnectionID, EquationImplementation, Graph, GraphImplementation, Interface
|
||||
from bedit_gui.models import Icon
|
||||
|
||||
|
||||
class AddEmptyGraphComponent(QUndoCommand):
|
||||
@@ -104,3 +105,25 @@ class DeleteComponent(QUndoCommand):
|
||||
values.insert(index, (item_id, item))
|
||||
items.clear()
|
||||
items.update(values)
|
||||
|
||||
|
||||
class PasteComponents(QUndoCommand):
|
||||
def __init__(self, document: object, target: dict[ComponentID, Component], components: dict[ComponentID, Component], icons: dict[ComponentID, Icon]) -> None:
|
||||
super().__init__("Paste components")
|
||||
self.document = document
|
||||
self.target = target
|
||||
self.components = components
|
||||
self.icons = icons
|
||||
|
||||
def redo(self) -> None:
|
||||
self.target.update(self.components)
|
||||
self.document.model_changed.emit(self.document.model)
|
||||
for component_id, icon in self.icons.items():
|
||||
self.document._set_component_icon(component_id, icon)
|
||||
|
||||
def undo(self) -> None:
|
||||
for component_id in self.components:
|
||||
self.target.pop(component_id, None)
|
||||
self.document.model_changed.emit(self.document.model)
|
||||
for component_id in self.icons:
|
||||
self.document._set_component_icon(component_id, None)
|
||||
|
||||
Reference in New Issue
Block a user