Loading editor/qml/DocumentTree.qml +33 −0 Original line number Diff line number Diff line Loading @@ -7,12 +7,45 @@ ColumnLayout { spacing: 0 property string selectedUuid: "" property var expandedUuids: ({}) Layout.preferredHeight: Math.max(200, docTreeView.rows * 30 + 30) function reload() { /* No-op: model is updated automatically via beginResetModel/endResetModel */ } function saveExpansionState() { var state = {} for (var row = 0; row < docTreeView.rows; ++row) { var idx = docTreeView.index(row, 0) if (docTreeView.isExpanded(row)) { var uid = docTreeView.model.data(idx, 258) // UuidRole = UserRole+2 = 258 if (uid) state[uid] = true } } expandedUuids = state } function restoreExpansionState() { for (var row = 0; row < docTreeView.rows; ++row) { var idx = docTreeView.index(row, 0) var uid = docTreeView.model.data(idx, 258) if (uid && expandedUuids[uid]) { docTreeView.expand(row) } } } Connections { target: localApi.documentTreeModel() function onModelAboutToBeReset() { treeRoot.saveExpansionState() } function onModelReset() { Qt.callLater(treeRoot.restoreExpansionState) } } Label { visible: docTreeView.rows === 0 text: qsTr("Empty document. Add a widget to start.") Loading Loading
editor/qml/DocumentTree.qml +33 −0 Original line number Diff line number Diff line Loading @@ -7,12 +7,45 @@ ColumnLayout { spacing: 0 property string selectedUuid: "" property var expandedUuids: ({}) Layout.preferredHeight: Math.max(200, docTreeView.rows * 30 + 30) function reload() { /* No-op: model is updated automatically via beginResetModel/endResetModel */ } function saveExpansionState() { var state = {} for (var row = 0; row < docTreeView.rows; ++row) { var idx = docTreeView.index(row, 0) if (docTreeView.isExpanded(row)) { var uid = docTreeView.model.data(idx, 258) // UuidRole = UserRole+2 = 258 if (uid) state[uid] = true } } expandedUuids = state } function restoreExpansionState() { for (var row = 0; row < docTreeView.rows; ++row) { var idx = docTreeView.index(row, 0) var uid = docTreeView.model.data(idx, 258) if (uid && expandedUuids[uid]) { docTreeView.expand(row) } } } Connections { target: localApi.documentTreeModel() function onModelAboutToBeReset() { treeRoot.saveExpansionState() } function onModelReset() { Qt.callLater(treeRoot.restoreExpansionState) } } Label { visible: docTreeView.rows === 0 text: qsTr("Empty document. Add a widget to start.") Loading