Added new and delete component actions

This commit is contained in:
2026-07-27 15:29:59 +02:00
parent a4daaa8798
commit 51a1537c9c
3 changed files with 139 additions and 1 deletions

View File

@@ -6,13 +6,14 @@ from pathlib import Path
from PySide6.QtCore import QObject, Signal
from PySide6.QtGui import QUndoStack
from bedit_core.models import ID, Component, ComponentID, GraphImplementation, Port, PortID, Parameter, ParameterID
from bedit_core.models import ID, Component, ComponentID, GraphImplementation, Port, PortID, Parameter, ParameterID, EquationImplementation
from bedit_core.models import Document as CoreDocument
from bedit_gui.commands.change_icon_command import ChangeIconCommand
from bedit_gui.commands.port_commands import AddPortCommand, ChangePortCommand, RemovePortCommand
from bedit_gui.commands.param_commands import AddParamCommand, ChangeParamCommand, RemoveParamCommand
from bedit_gui.commands.rename_component_command import RenameComponentCommand
from bedit_gui.commands.rename_document_command import RenameDocumentCommand
from bedit_gui.commands.component_command import AddEmptyGraphComponent, AddEmptyEquationComponent, DeleteComponent
from bedit_gui.models import Icon, IconDatabase
from bedit_gui.services import document_files
@@ -195,3 +196,14 @@ class Document(QObject):
for command in commands:
self.undo_stack.push(command)
self.undo_stack.endMacro()
def add_empty_graph_component(self, component: Component) -> None:
if isinstance(component.implementation, GraphImplementation):
self.undo_stack.push(AddEmptyGraphComponent(self, component))
def add_empty_equation_component(self, component: Component) -> None:
if isinstance(component.implementation, GraphImplementation):
self.undo_stack.push(AddEmptyEquationComponent(self, component))
def delete_component(self, component: Component) -> None:
self.undo_stack.push(DeleteComponent(self, component))