AI'ed clipboard

This commit is contained in:
Joppe Blondel
2026-07-27 16:42:16 +02:00
parent 5df9e53d58
commit 346a963acc
8 changed files with 492 additions and 10 deletions
@@ -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)