From 28933f2d4d83acf545efc654de08d497a3cda5c7 Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Mon, 11 Sep 2023 12:45:25 +0200 Subject: [PATCH] QmlDesigner: Expand and hide root item Hide and expand root item in the tree model of the connections editor search result. Change-Id: If6591077fee59542153f2167dfd43c8132b66c95 Reviewed-by: Thomas Hartmann --- .../ConnectionsDialogForm.qml | 11 ---------- .../connectionseditor/MyTreeViewDelegate.qml | 22 +++++-------------- .../connectionseditor/SuggestionPopup.qml | 13 ++++++----- 3 files changed, 12 insertions(+), 34 deletions(-) diff --git a/share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialogForm.qml b/share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialogForm.qml index 8b0404353b2..3b0f0fdaadd 100644 --- a/share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialogForm.qml +++ b/share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialogForm.qml @@ -16,17 +16,6 @@ Column { property var backend - - /* replaced by ConnectionModelStatementDelegate defined in C++ - enum ActionType { - CallFunction, - Assign, - ChangeState, - SetProperty, - PrintMessage, - Custom - } */ - y: StudioTheme.Values.popupMargin width: parent.width spacing: root.verticalSpacing diff --git a/share/qtcreator/qmldesigner/connectionseditor/MyTreeViewDelegate.qml b/share/qtcreator/qmldesigner/connectionseditor/MyTreeViewDelegate.qml index bccb6c645d6..366860b6757 100644 --- a/share/qtcreator/qmldesigner/connectionseditor/MyTreeViewDelegate.qml +++ b/share/qtcreator/qmldesigner/connectionseditor/MyTreeViewDelegate.qml @@ -9,36 +9,24 @@ import StudioTheme as StudioTheme T.TreeViewDelegate { id: control hoverEnabled: true - implicitWidth: 200 implicitHeight: 30 - - //implicitWidth: leftMargin + __contentIndent + implicitContentWidth + rightPadding + rightMargin - //implicitHeight: Math.max(indicator ? indicator.height : 0, implicitContentHeight) * 1.25 - indentation: 12 - //leftMargin: 4 - //rightMargin: 4 - //spacing: 4 - - //topPadding: contentItem ? (height - contentItem.implicitHeight) / 2 : 0 leftPadding: control.leftMargin + control.__contentIndent - //required property int row - //required property var model + readonly property int customDepth: control.depth - 1 + readonly property real __contentIndent: !control.isTreeNode ? 0 - : (control.depth * control.indentation) + : (control.customDepth * control.indentation) + (control.indicator ? control.indicator.width + control.spacing : 0) indicator: Item { - readonly property real __indicatorIndent: control.leftMargin + (control.depth * control.indentation) - - x: __indicatorIndent + x: control.leftMargin + (control.customDepth * control.indentation) width: 30 height: 30 Text { - id: caret + id: icon font.family: StudioTheme.Constants.iconFont.family font.pixelSize: StudioTheme.Values.smallIconFontSize color: control.hovered ? "#111111" : "white" // TODO colors diff --git a/share/qtcreator/qmldesigner/connectionseditor/SuggestionPopup.qml b/share/qtcreator/qmldesigner/connectionseditor/SuggestionPopup.qml index a4a1789eb55..eae421e927a 100644 --- a/share/qtcreator/qmldesigner/connectionseditor/SuggestionPopup.qml +++ b/share/qtcreator/qmldesigner/connectionseditor/SuggestionPopup.qml @@ -168,12 +168,13 @@ Controls.Popup { clip: true model: root.treeModel - // This is currently a workaround and should be cleaned up. Calling - // expandRecursively every time the filter changes is performance wise not good. - //Connections { - // target: proxyModel - // function onFilterChanged() { treeView.expandRecursively() } - //} + onLayoutChanged: function() { + treeView.expand(0) + } + + rowHeightProvider: function(row) { + return (row <= 0) ? 0 : -1 + } delegate: MyTreeViewDelegate { id: treeViewDelegate