on xenial help sign in
Fix collapsing of categories not working and the expansion/collapsing animation

+test. Approved by PS Jenkins bot, Michał Sawicz.

commitd506e7a7d1d2875afb57bdef6805a6ae01d14454 authorAlbert Astals <albert.astals@canonical.com> dateFri 6 Dec 2013, 12:39 (13 years ago) parente08a66071ea3b0
4 files changed+34−3
Components/FilterGrid.qml+1−1 Dash/DashFilterGrid.qml+6−2 Dash/GenericScopeView.qml+2 tests/qmltests/Dash/tst_GenericScopeView.qml+25
Components/FilterGrid.qml+1−1
@@ -67,7 +67,7 @@ Item {
6767 property alias highlightIndex: iconTileGrid.highlightIndex
6868 readonly property alias currentItem: iconTileGrid.currentItem
6969
70− implicitHeight: !filterAnimation.running ? childrenRect.height : height
70+ height: !filterAnimation.running ? childrenRect.height : height
7171 clip: filterAnimation.running
7272
7373 NumberAnimation {
Dash/DashFilterGrid.qml+6−2
@@ -37,7 +37,7 @@ DashRenderer {
3737 expandable: filterGrid.expandable
3838 delegateCreationBegin: filterGrid.delegateCreationBegin
3939 delegateCreationEnd: filterGrid.delegateCreationEnd
40− implicitHeight: filterGrid.implicitHeight
40+ height: filterGrid.height
4141 margins: filterGrid.margins
4242 uncollapsedHeight: filterGrid.uncollapsedHeight
4343 verticalSpacing: filterGrid.verticalSpacing
@@ -48,7 +48,7 @@ DashRenderer {
4848
4949 FilterGrid {
5050 id: filterGrid
51− anchors.fill: parent
51+ width: dashFilterGrid.width
5252 minimumHorizontalSpacing: units.gu(0.5)
5353 delegateWidth: units.gu(11)
5454 delegateHeight: units.gu(9.5)
@@ -56,5 +56,9 @@ DashRenderer {
5656 model: dashFilterGrid.model
5757 filter: dashFilterGrid.filter
5858 highlightIndex: dashFilterGrid.highlightIndex
59+
60+ onFilterChanged: {
61+ dashFilterGrid.filter = filter
62+ }
5963 }
6064}
Dash/GenericScopeView.qml+2
@@ -126,6 +126,7 @@ FocusScope {
126126
127127 delegate: ListItems.Base {
128128 id: baseItem
129+ objectName: "dashCategory" + category
129130 highlightWhenPressed: false
130131
131132 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
@@ -271,6 +272,7 @@ FocusScope {
271272
272273 sectionProperty: "name"
273274 sectionDelegate: ListItems.Header {
275+ objectName: "dashSectionHeader" + delegate.category
274276 property var delegate: categoryView.item(delegateIndex)
275277 width: categoryView.width
276278 text: section
tests/qmltests/Dash/tst_GenericScopeView.qml+25
@@ -19,6 +19,7 @@ import QtTest 1.0
1919import Unity 0.1
2020import ".."
2121import "../../../Dash"
22+import "../../../Components"
2223import Ubuntu.Components 0.1
2324import Unity.Test 0.1 as UT
2425
@@ -43,6 +44,7 @@ Item {
4344 GenericScopeView {
4445 id: genericScopeView
4546 anchors.fill: parent
47+ searchHistory: SearchHistoryModel {}
4648
4749 UT.UnityTestCase {
4850 name: "GenericScopeView"
@@ -223,6 +225,29 @@ Item {
223225 tryCompare(genericScopeView.scope, "searchQuery", "")
224226 }
225227
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+
226251 function test_showPreviewCarousel() {
227252 tryCompareFunction(function() { return findChild(genericScopeView, "carouselDelegate") != undefined; }, true);
228253 var tile = findChild(genericScopeView, "carouselDelegate");