Add link management: create, select, delete with undo/redo
Implement full link workflow between component slots on the wiresheet: - Link Mark / Link From / Link To context menu items for creating links - Link dialog with slot type validation and source/target swap button - Selectable link wires (click to highlight in red) with right-click delete - Undo/redo support for both add and delete link operations - Component deletion already cascades to remove related links Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -124,6 +124,41 @@ class AddComponentCommand:
|
||||
self.parent.insert(self.index, self.element)
|
||||
|
||||
|
||||
class AddLinkCommand:
|
||||
"""Adding a single link to the <links> section."""
|
||||
|
||||
def __init__(self, links_parent, link_element, label="add link"):
|
||||
self.links_parent = links_parent
|
||||
self.link_element = link_element
|
||||
self.label = label
|
||||
|
||||
def undo(self):
|
||||
if self.link_element in list(self.links_parent):
|
||||
self.links_parent.remove(self.link_element)
|
||||
|
||||
def redo(self):
|
||||
if self.link_element not in list(self.links_parent):
|
||||
self.links_parent.append(self.link_element)
|
||||
|
||||
|
||||
class DeleteLinkCommand:
|
||||
"""Removing a single link from the <links> section."""
|
||||
|
||||
def __init__(self, links_parent, index, link_element, label="delete link"):
|
||||
self.links_parent = links_parent
|
||||
self.index = index
|
||||
self.link_element = link_element
|
||||
self.label = label
|
||||
|
||||
def undo(self):
|
||||
if self.link_element not in list(self.links_parent):
|
||||
self.links_parent.insert(self.index, self.link_element)
|
||||
|
||||
def redo(self):
|
||||
if self.link_element in list(self.links_parent):
|
||||
self.links_parent.remove(self.link_element)
|
||||
|
||||
|
||||
class DeleteComponentCommand:
|
||||
"""A cascading delete: the component subtree plus every link that referenced it."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user