Fixed some stuff
This commit is contained in:
@@ -196,7 +196,7 @@ class GraphEditorClipboardHandler(ClipboardHandler):
|
||||
return self._target() is not None and self.clipboard.has_format(ClipboardService.COMPONENTS_MIME)
|
||||
|
||||
def can_delete(self) -> bool:
|
||||
return self.can_copy()
|
||||
return bool(self._selected_components() or self.editor.selected_connection_ids())
|
||||
|
||||
def copy(self) -> None:
|
||||
components = self._selected_components()
|
||||
@@ -225,7 +225,13 @@ class GraphEditorClipboardHandler(ClipboardHandler):
|
||||
self.document.paste_graph_components(graph_component, components, icons, positions)
|
||||
|
||||
def delete(self) -> None:
|
||||
self.document.delete_components(self._selected_components())
|
||||
components = self._selected_components()
|
||||
connection_ids = self.editor.selected_connection_ids()
|
||||
if components:
|
||||
self.document.delete_components(components)
|
||||
graph_component = self.editor.component()
|
||||
if graph_component is not None and connection_ids:
|
||||
self.document.delete_graph_connections(graph_component, connection_ids)
|
||||
|
||||
def _write_components(self, components: list[Component]) -> None:
|
||||
payload = export_components(self.document, components)
|
||||
|
||||
@@ -2,7 +2,7 @@ from collections.abc import Callable
|
||||
from functools import partial
|
||||
from typing import Protocol
|
||||
|
||||
from PySide6.QtCore import QEvent, QObject, QPoint, QSize, Qt
|
||||
from PySide6.QtCore import QEvent, QItemSelectionModel, QObject, QPoint, QSize, Qt
|
||||
from PySide6.QtGui import QMouseEvent
|
||||
from PySide6.QtWidgets import QAbstractItemView, QDialog, QHeaderView, QMenu
|
||||
|
||||
@@ -69,7 +69,10 @@ class DocumentTreeController(QObject):
|
||||
self.model.rename_component_requested.connect(self.document.rename_component)
|
||||
window.graph_editor.component_move_requested.connect(self.document.move_graph_component)
|
||||
window.graph_editor.component_context_menu_requested.connect(self._show_graph_component_context_menu)
|
||||
window.graph_editor.component_open_requested.connect(self._open_graph_component)
|
||||
window.graph_editor.connection_points_change_requested.connect(self.document.change_graph_connection_points)
|
||||
window.graph_editor.connection_add_requested.connect(self.document.add_graph_connection)
|
||||
window.graph_editor.connections_delete_requested.connect(self.document.delete_graph_connections)
|
||||
|
||||
# Add deselection with esc to this widget
|
||||
window.ui.actionEscape.setShortcutContext(Qt.ShortcutContext.WidgetWithChildrenShortcut)
|
||||
@@ -176,6 +179,12 @@ class DocumentTreeController(QObject):
|
||||
if component is not None:
|
||||
self._show_component_context_menu(component, global_position)
|
||||
|
||||
def _open_graph_component(self, component_id: ComponentID) -> None:
|
||||
index = self.model.component_index(component_id)
|
||||
if index.isValid():
|
||||
self.window.ui.documentTree.selectionModel().setCurrentIndex(index, QItemSelectionModel.SelectionFlag.ClearAndSelect | QItemSelectionModel.SelectionFlag.Rows)
|
||||
self.window.ui.documentTree.scrollTo(index)
|
||||
|
||||
def _show_component_context_menu(self, component: Component, global_position: QPoint) -> None:
|
||||
menu = QMenu(self.window.ui.documentTree)
|
||||
edit_interface = menu.addAction("Edit Interface")
|
||||
|
||||
@@ -62,6 +62,7 @@ class SimulationController(QObject):
|
||||
self.window.statusBar().showMessage(f"Compiling {component_path}…")
|
||||
logger.info("Compiling model: %s", component_path)
|
||||
try:
|
||||
self.document.infer_causality(component)
|
||||
build = self.compiler(component, build_directory)
|
||||
except (OSError, RuntimeError, ValueError) as exc:
|
||||
logger.exception("Could not compile model %s", component_path)
|
||||
|
||||
Reference in New Issue
Block a user