Document tree panel

This commit is contained in:
2026-07-26 15:25:51 +02:00
parent 9312ea544b
commit a96bde9642
3 changed files with 159 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
from PySide6.QtCore import QObject
from bedit_core.models import Document as CoreDocument
from bedit_gui.documents import Document
from bedit_gui.views.main_window import MainWindow
from bedit_gui.views.models.document_tree_model import DocumentTreeModel
class DocumentTreeController(QObject):
def __init__(
self,
document: Document,
window: MainWindow,
) -> None:
super().__init__(window)
self.document = document
self.window = window
self.model = DocumentTreeModel()
window.ui.documentTree.setModel(self.model)
document.model_changed.connect(self._on_document_changed)
window.ui.documentTree.setHeaderHidden(True)
self._on_document_changed(document.model)
def _on_document_changed(self, model: CoreDocument) -> None:
"""Rebuild the tree whenever New/Open replaces the core document."""
self.model.set_document(model)
# Optional presentation behavior. Later, you could instead remember
# expanded component IDs and restore only those nodes.
self.window.ui.documentTree.expandAll()