Fixed some bugs
This commit is contained in:
@@ -23,6 +23,7 @@ from bedit.gui.controllers.commands import (
|
||||
MoveInterfacePortCommand,
|
||||
PasteSelectionCommand,
|
||||
RenameConnectionCommand,
|
||||
RenameDocumentCommand,
|
||||
RenameInterfacePortCommand,
|
||||
ReplaceSourceCommand,
|
||||
RotateComponentsCommand,
|
||||
@@ -50,6 +51,7 @@ from bedit.gui.preferences import application_settings
|
||||
class DocumentController(QObject):
|
||||
documentReset = Signal()
|
||||
documentOpenedChanged = Signal(bool)
|
||||
documentNameChanged = Signal(str)
|
||||
activeGraphChanged = Signal()
|
||||
componentAdded = Signal(str)
|
||||
componentRemoved = Signal(str)
|
||||
@@ -228,10 +230,19 @@ class DocumentController(QObject):
|
||||
{component_id: component},
|
||||
connections,
|
||||
[],
|
||||
[],
|
||||
)
|
||||
)
|
||||
|
||||
def rename_document(self, name: str) -> None:
|
||||
if self.document is None:
|
||||
return
|
||||
name = name.strip()
|
||||
if not name:
|
||||
raise ValueError("The document name cannot be empty")
|
||||
old = str(self.document.metadata.get("name") or "Current Document")
|
||||
if name != old:
|
||||
self.undo_stack.push(RenameDocumentCommand(self, old, name))
|
||||
|
||||
def add_component_copy(self, source: Component, position: QPointF) -> str:
|
||||
if self.active_component is None or self.active_component.implementation_kind != "graph":
|
||||
raise ValueError("Open a graph component before placing components")
|
||||
@@ -1374,6 +1385,12 @@ class DocumentController(QObject):
|
||||
connection.name = name
|
||||
self.documentReset.emit()
|
||||
|
||||
def _rename_document(self, name: str) -> None:
|
||||
if self.document is None:
|
||||
return
|
||||
self.document.metadata["name"] = name
|
||||
self.documentNameChanged.emit(name)
|
||||
|
||||
def _replace_source(self, component_id: str, source: dict) -> None:
|
||||
if self.document is None:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user