@@ -30,7 +30,7 @@ Item {
3030
3131 /* If true, the number of elements displayed will be limited by collapsedRowCount.
3232 If false, all elements will be displayed, effectively looking the same as a regular
33− ResponsiveGridView. */
33+ ResponsiveGridView. Manipulate this property through setFilter */
3434 property bool filter: true
3535
3636 /* Whether, when collapsed, a button should be displayed enabling the user to expand
@@ -66,29 +66,35 @@ Item {
6666 property alias highlightIndex: iconTileGrid.highlightIndex
6767 readonly property alias currentItem: iconTileGrid.currentItem
6868
69− height: !filterAnimation.running ? childrenRect.height : height
69+ height: filter ? root.collapsedHeight : root.uncollapsedHeight
7070 clip: filterAnimation.running
7171
72− NumberAnimation {
73− property bool filterEndValue
74− id: filterAnimation
75− target: root
76− property: "height"
77− to: filterEndValue ? root.collapsedHeight : root.uncollapsedHeight
78− // Duration and easing here match the ListViewWithPageHeader::m_contentYAnimation
79− // otherwise since both animations can run at the same time you'll get
80− // some visual weirdness.
81− duration: 200
82− easing.type: Easing.InOutQuad
83− onStopped: {
84− root.filter = filterEndValue;
72+ Behavior on height {
73+ id: heightBehaviour
74+ enabled: false
75+ NumberAnimation {
76+ id: filterAnimation
77+ // Duration and easing here match the ListViewWithPageHeader::m_contentYAnimation
78+ // otherwise since both animations can run at the same time you'll get
79+ // some visual weirdness.
80+ duration: 200
81+ easing.type: Easing.InOutQuad
82+ onRunningChanged: {
83+ if (!running) {
84+ limitModel.filter = root.filter;
85+ }
86+ heightBehaviour.enabled = false;
87+ }
8588 }
8689 }
8790
88− function startFilterAnimation(filter) {
89− filterAnimation.filterEndValue = filter
90− filterAnimation.start();
91− }
91+ function setFilter(filter, animate) {
92+ heightBehaviour.enabled = animate;
93+ root.filter = filter;
94+ if (!animate || !filter) {
95+ limitModel.filter = filter;
96+ }
97+ }
9298
9399 ResponsiveGridView {
94100 id: iconTileGrid
@@ -104,8 +110,16 @@ Item {
104110 verticalSpacing: units.gu(2)
105111
106112 model: LimitProxyModel {
113+ id: limitModel
114+ // We do have another filter property here because
115+ // we can't directly use filter from the root since we need to decouple
116+ // the real filtering with the animation since the closing animation
117+ // i.e. filter=false we still need to not be filtering until
118+ // t he animation finishes otherwise we hide the items when the animation
119+ // is still running
120+ property bool filter: true
107121 model: root.model
108− limit: (filter && !filterAnimation.running) ? rowsWhenCollapsed * iconTileGrid.columns : -1
122+ limit: filter ? rowsWhenCollapsed * iconTileGrid.columns : -1
109123 }
110124 }
111125}