Copy/paste on canvas

This commit is contained in:
Joppe Blondel
2026-08-17 12:12:57 +02:00
parent fcee2ac8b6
commit 0bb2141673
8 changed files with 182 additions and 49 deletions
+10
View File
@@ -322,6 +322,16 @@ class Document(QObject):
names.add(component.name)
self.undo_stack.push(PasteComponents(self, target, components, icons))
def paste_graph_components(self, graph_component: Component, components: dict[ComponentID, Component], icons: dict[ComponentID, Icon], positions: dict[ComponentID, tuple[int, int]]) -> None:
if not isinstance(graph_component.implementation, GraphImplementation) or not components:
return
target = graph_component.implementation.graph.components
names = {component.name for component in target.values()}
for component in components.values():
component.name = self._unique_name(names, component.name)
names.add(component.name)
self.undo_stack.push(PasteComponents(self, target, components, icons, self.component_id(graph_component), positions))
@staticmethod
def _unique_component_name(components: dict[ComponentID, Component], name: str) -> str:
return Document._unique_name({component.name for component in components.values()}, name)