From 923bd79323eedb982ff9c2fe1cdda6d8e7819a39 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 23 Apr 2020 14:12:15 +0300 Subject: [PATCH] QmlDesigner: Don't expand the selected node on selection change Point of expanding items at selection change is to ensure the selected item is visible. It is not necessary to also expand the selected item. Change-Id: I2435daf4845b5066ddb41a4aeae71d66e12fd94d Fixes: QDS-1940 Reviewed-by: Thomas Hartmann Reviewed-by: Mahmoud Badri --- .../qmldesigner/components/navigator/navigatorview.cpp | 6 +++--- .../qmldesigner/components/navigator/navigatorview.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp index e953d6b6df5..1c2d73be6dc 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp +++ b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp @@ -442,7 +442,7 @@ void NavigatorView::updateItemSelection() // make sure selected nodes a visible foreach (const QModelIndex &selectedIndex, itemSelection.indexes()) { if (selectedIndex.column() == 0) - expandRecursively(selectedIndex); + expandAncestors(selectedIndex); } } @@ -466,9 +466,9 @@ bool NavigatorView::blockSelectionChangedSignal(bool block) return oldValue; } -void NavigatorView::expandRecursively(const QModelIndex &index) +void NavigatorView::expandAncestors(const QModelIndex &index) { - QModelIndex currentIndex = index; + QModelIndex currentIndex = index.parent(); while (currentIndex.isValid()) { if (!treeWidget()->isExpanded(currentIndex)) treeWidget()->expand(currentIndex); diff --git a/src/plugins/qmldesigner/components/navigator/navigatorview.h b/src/plugins/qmldesigner/components/navigator/navigatorview.h index 529d263d407..3bafe0fa80b 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatorview.h +++ b/src/plugins/qmldesigner/components/navigator/navigatorview.h @@ -110,7 +110,7 @@ protected: //functions QTreeView *treeWidget() const; NavigatorTreeModel *treeModel(); bool blockSelectionChangedSignal(bool block); - void expandRecursively(const QModelIndex &index); + void expandAncestors(const QModelIndex &index); void reparentAndCatch(NodeAbstractProperty property, const ModelNode &modelNode); void setupWidget();