on xenial help sign in
A bit more of reog
46f012dAlbert Astals
qml/Components/FilterGrid.qml+12−15
@@ -28,14 +28,6 @@ import "../Components"
28Item {
28Item {
29 id: root
29 id: root
30
30
31− QtObject {
32− id: d
33− /* If true, the number of elements displayed will be limited by collapsedRowCount.
34− If false, all elements will be displayed, effectively looking the same as a regular
35− ResponsiveGridView. Manipulate this property through setFilter */
36− property bool filter: true
37− }
38−
39 /* Whether, when collapsed, a button should be displayed enabling the user to expand
31 /* Whether, when collapsed, a button should be displayed enabling the user to expand
40 the grid to its full size. */
32 the grid to its full size. */
41 readonly property bool expandable: model.count > rowsWhenCollapsed * iconTileGrid.columns
33 readonly property bool expandable: model.count > rowsWhenCollapsed * iconTileGrid.columns
@@ -68,8 +60,9 @@ Item {
68 readonly property alias pressDelay: iconTileGrid.pressDelay
60 readonly property alias pressDelay: iconTileGrid.pressDelay
69 property alias highlightIndex: iconTileGrid.highlightIndex
61 property alias highlightIndex: iconTileGrid.highlightIndex
70 readonly property alias currentItem: iconTileGrid.currentItem
62 readonly property alias currentItem: iconTileGrid.currentItem
63+ readonly property alias filtered: limitModel.filter
71
64
72− height: d.filter ? root.collapsedHeight : root.uncollapsedHeight
65+ height: d.collapsed ? root.collapsedHeight : root.uncollapsedHeight
73 clip: filterAnimation.running
66 clip: filterAnimation.running
74
67
75 Behavior on height {
68 Behavior on height {
@@ -84,16 +77,21 @@ Item {
84 easing.type: Easing.InOutQuad
77 easing.type: Easing.InOutQuad
85 onRunningChanged: {
78 onRunningChanged: {
86 if (!running) {
79 if (!running) {
87− limitModel.filter = d.filter;
80+ limitModel.filter = d.collapsed;
88 }
81 }
89 heightBehaviour.enabled = false;
82 heightBehaviour.enabled = false;
90 }
83 }
91 }
84 }
92 }
85 }
93
86
87+ QtObject {
88+ id: d
89+ property bool collapsed: true
90+ }
91+
94 function setFilter(filter, animate) {
92 function setFilter(filter, animate) {
95 heightBehaviour.enabled = animate;
93 heightBehaviour.enabled = animate;
96− d.filter = filter;
94+ d.collapsed = filter;
97 if (!animate || !filter) {
95 if (!animate || !filter) {
98 limitModel.filter = filter;
96 limitModel.filter = filter;
99 }
97 }
@@ -114,11 +112,10 @@ Item {
114
112
115 model: LimitProxyModel {
113 model: LimitProxyModel {
116 id: limitModel
114 id: limitModel
117− // We do have another filter property here because
115+ // We do have filter and collapsed propertis because we need to decouple
118− // we can't directly use filter from the root since we need to decouple
119 // the real filtering with the animation since the closing animation
116 // the real filtering with the animation since the closing animation
120− // i.e. filter=false we still need to not be filtering until
117+ // i.e. setFilter(false. true) we still need to not be filtering until
121− // t he animation finishes otherwise we hide the items when the animation
118+ // the animation finishes otherwise we hide the items when the animation
122 // is still running
119 // is still running
123 property bool filter: true
120 property bool filter: true
124 model: root.model
121 model: root.model
qml/Dash/CardFilterGrid.qml+1
@@ -28,6 +28,7 @@ DashRenderer {
28 verticalSpacing: units.gu(1)
28 verticalSpacing: units.gu(1)
29 currentItem: filterGrid.currentItem
29 currentItem: filterGrid.currentItem
30 height: filterGrid.height
30 height: filterGrid.height
31+ filtered: filterGrid.filtered
31
32
32 function setFilter(filter, animate) {
33 function setFilter(filter, animate) {
33 filterGrid.setFilter(filter, animate)
34 filterGrid.setFilter(filter, animate)
qml/Dash/DashRenderer.qml+3
@@ -20,6 +20,9 @@ Item {
20 // Can the item be expanded?
20 // Can the item be expanded?
21 property bool expandable: false
21 property bool expandable: false
22
22
23+ // In case it can be expanded, is it filtered
24+ property bool filtered: true
25+
23 property int collapsedHeight: height
26 property int collapsedHeight: height
24
27
25 property int margins: 0
28 property int margins: 0
qml/Dash/GenericScopeView.qml+1−1
@@ -121,7 +121,7 @@ FocusScope {
121 showDivider: false
121 showDivider: false
122
122
123 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
123 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
124− readonly property bool filtered: categoryView.expandedCategoryId != categoryId
124+ readonly property bool filtered: rendererLoader.item ? rendererLoader.item.filtered : true
125 readonly property string category: categoryId
125 readonly property string category: categoryId
126 readonly property var item: rendererLoader.item
126 readonly property var item: rendererLoader.item
127
127
tests/qmltests/Dash/tst_GenericScopeView.qml+3−3
@@ -140,7 +140,7 @@ Item {
140 mouseClick(header, header.width / 2, header.height / 2);
140 mouseClick(header, header.width / 2, header.height / 2);
141 tryCompareFunction(function() { middleHeight = category.height; return category.height > initialHeight; }, true);
141 tryCompareFunction(function() { middleHeight = category.height; return category.height > initialHeight; }, true);
142 tryCompare(category, "filtered", false);
142 tryCompare(category, "filtered", false);
143− verify(category.height > middleHeight);
143+ tryCompareFunction(function() { return category.height > middleHeight; }, true);
144
144
145 mouseClick(header, header.width / 2, header.height / 2);
145 mouseClick(header, header.width / 2, header.height / 2);
146 verify(category.expandable);
146 verify(category.expandable);
@@ -165,7 +165,7 @@ Item {
165
165
166 mouseClick(header2, header2.width / 2, header2.height / 2);
166 mouseClick(header2, header2.width / 2, header2.height / 2);
167 tryCompare(category2, "filtered", false);
167 tryCompare(category2, "filtered", false);
168− tryCompare(category2FilterGrid, "filter", false);
168+ tryCompare(category2FilterGrid, "filtered", false);
169
169
170 categoryListView.positionAtBeginning();
170 categoryListView.positionAtBeginning();
171
171
@@ -182,7 +182,7 @@ Item {
182 mouseClick(header0, header0.width / 2, header0.height / 2);
182 mouseClick(header0, header0.width / 2, header0.height / 2);
183 tryCompare(category0, "filtered", false);
183 tryCompare(category0, "filtered", false);
184 tryCompare(category2, "filtered", true);
184 tryCompare(category2, "filtered", true);
185− tryCompare(category2FilterGrid, "filter", true);
185+ tryCompare(category2FilterGrid, "filtered", true);
186 mouseClick(header0, header0.width / 2, header0.height / 2);
186 mouseClick(header0, header0.width / 2, header0.height / 2);
187 tryCompare(category0, "filtered", true);
187 tryCompare(category0, "filtered", true);
188 tryCompare(category2, "filtered", true);
188 tryCompare(category2, "filtered", true);