This commit is contained in:
2026-08-17 13:03:29 +02:00
parent 4591e6b7b0
commit a61c8e6003
6 changed files with 204 additions and 7 deletions

View File

@@ -0,0 +1,24 @@
from copy import deepcopy
from PySide6.QtGui import QUndoCommand
from bedit_core.models import ComponentID
from bedit_gui.models import GraphComponentLabel
class ChangeGraphComponentLabelCommand(QUndoCommand):
def __init__(self, document: object, graph_id: ComponentID, component_id: ComponentID, label: GraphComponentLabel, text: str) -> None:
super().__init__(text)
self.document = document
self.graph_id = graph_id
self.component_id = component_id
database = document._graph_database(False)
graph = database.graphs.get(graph_id) if database is not None else None
self.old_label = deepcopy(graph.component_labels.get(component_id)) if graph is not None and component_id in graph.component_labels else None
self.new_label = deepcopy(label)
def redo(self) -> None:
self.document._set_graph_component_label(self.graph_id, self.component_id, self.new_label)
def undo(self) -> None:
self.document._set_graph_component_label(self.graph_id, self.component_id, self.old_label)