on xenial help sign in
Remember the expanded categoryId and not the index

The index can change on search, and we still want to maintain it expanded in that case

commit79502299762be52e9d94c0a1ef6d564a0fb60dfe authorAlbert Astals <albert.astals@canonical.com> dateThu 26 Sep 2013, 12:01 (13 years ago) parentc0075cb
1 file changed+8−7
Dash/GenericScopeView.qml+8−7
Dash/GenericScopeView.qml+8−7
@@ -59,13 +59,14 @@ ScopeView {
5959 onAtYEndChanged: if (atYEnd) endReached()
6060 onMovingChanged: if (moving && atYEnd) endReached()
6161
62− property int expandedIndex: -1
62+ property string expandedCategoryId: ""
6363
6464 delegate: ListItems.Base {
6565 highlightWhenPressed: false
6666
6767 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
6868 readonly property bool filtered: rendererLoader.item ? rendererLoader.item.filter : true
69+ readonly property string category: rendererLoader.item ? rendererLoader.item.objectName : ""
6970
7071 Loader {
7172 id: rendererLoader
@@ -87,7 +88,7 @@ ScopeView {
8788 }
8889 item.objectName = Qt.binding(function() { return categoryId })
8990 if (item.expandable) {
90− var shouldFilter = index != categoryView.expandedIndex;
91+ var shouldFilter = item.objectName != categoryView.expandedCategoryId;
9192 if (shouldFilter != item.filter) {
9293 item.filter = shouldFilter;
9394 }
@@ -123,10 +124,10 @@ ScopeView {
123124 }
124125 Connections {
125126 target: categoryView
126− onExpandedIndexChanged: {
127+ onExpandedCategoryIdChanged: {
127128 var item = rendererLoader.item;
128129 if (item.expandable) {
129− var shouldFilter = index != categoryView.expandedIndex;
130+ var shouldFilter = item.objectName != categoryView.expandedCategoryId;
130131 if (shouldFilter != item.filter) {
131132 // If the filter animation will be seen start it, otherwise, just flip the switch
132133 var shrinkingVisible = shouldFilter && y + item.collapsedHeight < categoryView.height;
@@ -157,10 +158,10 @@ ScopeView {
157158 return "";
158159 }
159160 onClicked: {
160− if (categoryView.expandedIndex != delegateIndex)
161− categoryView.expandedIndex = delegateIndex;
161+ if (categoryView.expandedCategoryId != delegate.category)
162+ categoryView.expandedCategoryId = delegate.category;
162163 else
163− categoryView.expandedIndex = -1;
164+ categoryView.expandedCategoryId = "";
164165 }
165166 }
166167 pageHeader: PageHeader {