on xenial help sign in
A bit more of reog
commit46f012dc6210f6ff930432c3160eb74a0e77c1d6 authorAlbert Astals <albert.astals@canonical.com> dateWed 16 Apr 2014, 17:55 (13 years ago) parent2fc6ede
5 files changed+20−19
qml/Components/FilterGrid.qml+12−15 qml/Dash/CardFilterGrid.qml+1 qml/Dash/DashRenderer.qml+3 qml/Dash/GenericScopeView.qml+1−1 tests/qmltests/Dash/tst_GenericScopeView.qml+3−3
qml/Components/FilterGrid.qml+12−15
@@ -28,14 +28,6 @@ import "../Components"
2828Item {
2929 id: root
3030
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−
3931 /* Whether, when collapsed, a button should be displayed enabling the user to expand
4032 the grid to its full size. */
4133 readonly property bool expandable: model.count > rowsWhenCollapsed * iconTileGrid.columns
@@ -68,8 +60,9 @@ Item {
6860 readonly property alias pressDelay: iconTileGrid.pressDelay
6961 property alias highlightIndex: iconTileGrid.highlightIndex
7062 readonly property alias currentItem: iconTileGrid.currentItem
63+ readonly property alias filtered: limitModel.filter
7164
72− height: d.filter ? root.collapsedHeight : root.uncollapsedHeight
65+ height: d.collapsed ? root.collapsedHeight : root.uncollapsedHeight
7366 clip: filterAnimation.running
7467
7568 Behavior on height {
@@ -84,16 +77,21 @@ Item {
8477 easing.type: Easing.InOutQuad
8578 onRunningChanged: {
8679 if (!running) {
87− limitModel.filter = d.filter;
80+ limitModel.filter = d.collapsed;
8881 }
8982 heightBehaviour.enabled = false;
9083 }
9184 }
9285 }
9386
87+ QtObject {
88+ id: d
89+ property bool collapsed: true
90+ }
91+
9492 function setFilter(filter, animate) {
9593 heightBehaviour.enabled = animate;
96− d.filter = filter;
94+ d.collapsed = filter;
9795 if (!animate || !filter) {
9896 limitModel.filter = filter;
9997 }
@@ -114,11 +112,10 @@ Item {
114112
115113 model: LimitProxyModel {
116114 id: limitModel
117− // We do have another filter property here because
118− // we can't directly use filter from the root since we need to decouple
115+ // We do have filter and collapsed propertis because we need to decouple
119116 // the real filtering with the animation since the closing animation
120− // i.e. filter=false we still need to not be filtering until
121− // t he animation finishes otherwise we hide the items when the animation
117+ // i.e. setFilter(false. true) we still need to not be filtering until
118+ // the animation finishes otherwise we hide the items when the animation
122119 // is still running
123120 property bool filter: true
124121 model: root.model
qml/Dash/CardFilterGrid.qml+1
@@ -28,6 +28,7 @@ DashRenderer {
2828 verticalSpacing: units.gu(1)
2929 currentItem: filterGrid.currentItem
3030 height: filterGrid.height
31+ filtered: filterGrid.filtered
3132
3233 function setFilter(filter, animate) {
3334 filterGrid.setFilter(filter, animate)
qml/Dash/DashRenderer.qml+3
@@ -20,6 +20,9 @@ Item {
2020 // Can the item be expanded?
2121 property bool expandable: false
2222
23+ // In case it can be expanded, is it filtered
24+ property bool filtered: true
25+
2326 property int collapsedHeight: height
2427
2528 property int margins: 0
qml/Dash/GenericScopeView.qml+1−1
@@ -121,7 +121,7 @@ FocusScope {
121121 showDivider: false
122122
123123 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
125125 readonly property string category: categoryId
126126 readonly property var item: rendererLoader.item
127127
tests/qmltests/Dash/tst_GenericScopeView.qml+3−3
@@ -140,7 +140,7 @@ Item {
140140 mouseClick(header, header.width / 2, header.height / 2);
141141 tryCompareFunction(function() { middleHeight = category.height; return category.height > initialHeight; }, true);
142142 tryCompare(category, "filtered", false);
143− verify(category.height > middleHeight);
143+ tryCompareFunction(function() { return category.height > middleHeight; }, true);
144144
145145 mouseClick(header, header.width / 2, header.height / 2);
146146 verify(category.expandable);
@@ -165,7 +165,7 @@ Item {
165165
166166 mouseClick(header2, header2.width / 2, header2.height / 2);
167167 tryCompare(category2, "filtered", false);
168− tryCompare(category2FilterGrid, "filter", false);
168+ tryCompare(category2FilterGrid, "filtered", false);
169169
170170 categoryListView.positionAtBeginning();
171171
@@ -182,7 +182,7 @@ Item {
182182 mouseClick(header0, header0.width / 2, header0.height / 2);
183183 tryCompare(category0, "filtered", false);
184184 tryCompare(category2, "filtered", true);
185− tryCompare(category2FilterGrid, "filter", true);
185+ tryCompare(category2FilterGrid, "filtered", true);
186186 mouseClick(header0, header0.width / 2, header0.height / 2);
187187 tryCompare(category0, "filtered", true);
188188 tryCompare(category2, "filtered", true);