on xenial help sign in
Fix collapsing of categories not working and the expansion/collapsing animation
d506e7aAlbert Astals
Components/FilterGrid.qml+1−1
@@ -67,7 +67,7 @@ Item {
67 property alias highlightIndex: iconTileGrid.highlightIndex
67 property alias highlightIndex: iconTileGrid.highlightIndex
68 readonly property alias currentItem: iconTileGrid.currentItem
68 readonly property alias currentItem: iconTileGrid.currentItem
69
69
70− implicitHeight: !filterAnimation.running ? childrenRect.height : height
70+ height: !filterAnimation.running ? childrenRect.height : height
71 clip: filterAnimation.running
71 clip: filterAnimation.running
72
72
73 NumberAnimation {
73 NumberAnimation {
Dash/DashFilterGrid.qml+6−2
@@ -37,7 +37,7 @@ DashRenderer {
37 expandable: filterGrid.expandable
37 expandable: filterGrid.expandable
38 delegateCreationBegin: filterGrid.delegateCreationBegin
38 delegateCreationBegin: filterGrid.delegateCreationBegin
39 delegateCreationEnd: filterGrid.delegateCreationEnd
39 delegateCreationEnd: filterGrid.delegateCreationEnd
40− implicitHeight: filterGrid.implicitHeight
40+ height: filterGrid.height
41 margins: filterGrid.margins
41 margins: filterGrid.margins
42 uncollapsedHeight: filterGrid.uncollapsedHeight
42 uncollapsedHeight: filterGrid.uncollapsedHeight
43 verticalSpacing: filterGrid.verticalSpacing
43 verticalSpacing: filterGrid.verticalSpacing
@@ -48,7 +48,7 @@ DashRenderer {
48
48
49 FilterGrid {
49 FilterGrid {
50 id: filterGrid
50 id: filterGrid
51− anchors.fill: parent
51+ width: dashFilterGrid.width
52 minimumHorizontalSpacing: units.gu(0.5)
52 minimumHorizontalSpacing: units.gu(0.5)
53 delegateWidth: units.gu(11)
53 delegateWidth: units.gu(11)
54 delegateHeight: units.gu(9.5)
54 delegateHeight: units.gu(9.5)
@@ -56,5 +56,9 @@ DashRenderer {
56 model: dashFilterGrid.model
56 model: dashFilterGrid.model
57 filter: dashFilterGrid.filter
57 filter: dashFilterGrid.filter
58 highlightIndex: dashFilterGrid.highlightIndex
58 highlightIndex: dashFilterGrid.highlightIndex
59+
60+ onFilterChanged: {
61+ dashFilterGrid.filter = filter
62+ }
59 }
63 }
60}
64}
Dash/GenericScopeView.qml+2
@@ -126,6 +126,7 @@ FocusScope {
126
126
127 delegate: ListItems.Base {
127 delegate: ListItems.Base {
128 id: baseItem
128 id: baseItem
129+ objectName: "dashCategory" + category
129 highlightWhenPressed: false
130 highlightWhenPressed: false
130
131
131 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
132 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
@@ -271,6 +272,7 @@ FocusScope {
271
272
272 sectionProperty: "name"
273 sectionProperty: "name"
273 sectionDelegate: ListItems.Header {
274 sectionDelegate: ListItems.Header {
275+ objectName: "dashSectionHeader" + delegate.category
274 property var delegate: categoryView.item(delegateIndex)
276 property var delegate: categoryView.item(delegateIndex)
275 width: categoryView.width
277 width: categoryView.width
276 text: section
278 text: section
tests/qmltests/Dash/tst_GenericScopeView.qml+25
@@ -19,6 +19,7 @@ import QtTest 1.0
19import Unity 0.1
19import Unity 0.1
20import ".."
20import ".."
21import "../../../Dash"
21import "../../../Dash"
22+import "../../../Components"
22import Ubuntu.Components 0.1
23import Ubuntu.Components 0.1
23import Unity.Test 0.1 as UT
24import Unity.Test 0.1 as UT
24
25
@@ -43,6 +44,7 @@ Item {
43 GenericScopeView {
44 GenericScopeView {
44 id: genericScopeView
45 id: genericScopeView
45 anchors.fill: parent
46 anchors.fill: parent
47+ searchHistory: SearchHistoryModel {}
46
48
47 UT.UnityTestCase {
49 UT.UnityTestCase {
48 name: "GenericScopeView"
50 name: "GenericScopeView"
@@ -223,6 +225,29 @@ Item {
223 tryCompare(genericScopeView.scope, "searchQuery", "")
225 tryCompare(genericScopeView.scope, "searchQuery", "")
224 }
226 }
225
227
228+ function test_filter_expand_collapse() {
229+ // wait for the item to be there
230+ tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader0") != undefined; }, true);
231+
232+ var header = findChild(genericScopeView, "dashSectionHeader0")
233+ var category = findChild(genericScopeView, "dashCategory0")
234+
235+ waitForRendering(header);
236+ verify(category.expandable);
237+ verify(category.filtered);
238+
239+ var initialHeight = category.height;
240+ var middleHeight;
241+ mouseClick(header, header.width / 2, header.height / 2);
242+ tryCompareFunction(function() { middleHeight = category.height; return category.height > initialHeight; }, true);
243+ tryCompare(category, "filtered", false);
244+ verify(category.height > middleHeight);
245+
246+ mouseClick(header, header.width / 2, header.height / 2);
247+ verify(category.expandable);
248+ tryCompare(category, "filtered", true);
249+ }
250+
226 function test_showPreviewCarousel() {
251 function test_showPreviewCarousel() {
227 tryCompareFunction(function() { return findChild(genericScopeView, "carouselDelegate") != undefined; }, true);
252 tryCompareFunction(function() { return findChild(genericScopeView, "carouselDelegate") != undefined; }, true);
228 var tile = findChild(genericScopeView, "carouselDelegate");
253 var tile = findChild(genericScopeView, "carouselDelegate");