Merge lp:~fboucault/unity-2d/renderer_grid_limit_count into lp:unity-2d/3.0

Proposed by Florian Boucault
Status: Superseded
Proposed branch: lp:~fboucault/unity-2d/renderer_grid_limit_count
Merge into: lp:unity-2d/3.0
Diff against target: 618 lines (+506/-11)
5 files modified
libunity-2d-private/Unity2d/qsortfilterproxymodelqml.cpp (+100/-1)
libunity-2d-private/Unity2d/qsortfilterproxymodelqml.h (+13/-0)
libunity-2d-private/tests/CMakeLists.txt (+1/-0)
libunity-2d-private/tests/qsortfilterproxymodeltest.cpp (+380/-0)
places/RendererGrid.qml (+12/-10)
To merge this branch: bzr merge lp:~fboucault/unity-2d/renderer_grid_limit_count
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
Review via email: mp+69444@code.launchpad.net

Description of the change

[dash] RendererGrid: actually filter out the items that are not displayed because of group folding.

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote :

No problems as far as I can see. Accept

review: Approve

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libunity-2d-private/Unity2d/qsortfilterproxymodelqml.cpp'
2--- libunity-2d-private/Unity2d/qsortfilterproxymodelqml.cpp 2011-07-15 10:57:31 +0000
3+++ libunity-2d-private/Unity2d/qsortfilterproxymodelqml.cpp 2011-07-27 12:25:44 +0000
4@@ -18,8 +18,11 @@
5 #include <debug_p.h>
6
7 QSortFilterProxyModelQML::QSortFilterProxyModelQML(QObject *parent) :
8- QSortFilterProxyModel(parent)
9+ QSortFilterProxyModel(parent), m_limit(-1)
10 {
11+ connect(this, SIGNAL(modelReset()), SIGNAL(countChanged()));
12+ connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), SIGNAL(countChanged()));
13+ connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), SIGNAL(countChanged()));
14 }
15
16 void QSortFilterProxyModelQML::setRoleNames(const QHash<int,QByteArray> &roleNames)
17@@ -64,6 +67,12 @@
18 setRoleNames(itemModel->roleNames());
19
20 setSourceModel(itemModel);
21+
22+ connect(itemModel, SIGNAL(modelReset()), SIGNAL(totalCountChanged()));
23+ connect(itemModel, SIGNAL(rowsInserted(QModelIndex,int,int)), SIGNAL(totalCountChanged()));
24+ connect(itemModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), SIGNAL(totalCountChanged()));
25+ Q_EMIT totalCountChanged();
26+ Q_EMIT countChanged();
27 }
28
29 QVariantMap
30@@ -85,7 +94,97 @@
31 }
32
33 int
34+QSortFilterProxyModelQML::totalCount() const
35+{
36+ if (sourceModel() != NULL) {
37+ return sourceModel()->rowCount();
38+ } else {
39+ return 0;
40+ }
41+}
42+
43+int
44 QSortFilterProxyModelQML::count()
45 {
46 return rowCount();
47 }
48+
49+int
50+QSortFilterProxyModelQML::rowCount(const QModelIndex &parent) const
51+{
52+ int count = QSortFilterProxyModel::rowCount(parent);
53+ if (m_limit >= 0) {
54+ return qMin(count, m_limit);
55+ } else {
56+ return count;
57+ }
58+}
59+
60+int
61+QSortFilterProxyModelQML::limit() const
62+{
63+ return m_limit;
64+}
65+
66+void
67+QSortFilterProxyModelQML::setLimit(int limit)
68+{
69+ if (limit != m_limit) {
70+ int count = QSortFilterProxyModel::rowCount();
71+ int start;
72+ int end;
73+ bool inserted = false;
74+ bool removed = false;
75+
76+ if (m_limit == -1) {
77+ if (limit < count) {
78+ start = qMin(count, limit);
79+ end = count-1;
80+ removed = true;
81+ }
82+ } else if (limit == -1) {
83+ if (m_limit < count) {
84+ start = qMin(count, m_limit);
85+ end = count-1;
86+ inserted = true;
87+ }
88+ } else if (m_limit >= count && limit >= count) {
89+ // Nothing
90+ } else if (m_limit >= count && limit < count) {
91+ start = qMin(count, limit);
92+ end = count-1;
93+ removed = true;
94+ } else if (m_limit < count && limit >= count) {
95+ start = qMin(count, m_limit);
96+ end = count-1;
97+ inserted = true;
98+ } else if (m_limit < count && limit < count) {
99+ if (m_limit < limit) {
100+ start = qMin(count, m_limit);
101+ end = qMin(count, limit)-1;
102+ inserted = true;
103+ } else {
104+ start = qMin(count, limit);
105+ end = qMin(count, m_limit)-1;
106+ removed = true;
107+ }
108+ }
109+
110+ if (inserted) {
111+ beginInsertRows(QModelIndex(), start, end);
112+ }
113+ if (removed) {
114+ beginRemoveRows(QModelIndex(), start, end);
115+ }
116+ m_limit = limit;
117+
118+ if (inserted) {
119+ endInsertRows();
120+ }
121+ if (removed) {
122+ endRemoveRows();
123+ }
124+
125+ Q_EMIT limitChanged();
126+ }
127+}
128
129=== modified file 'libunity-2d-private/Unity2d/qsortfilterproxymodelqml.h'
130--- libunity-2d-private/Unity2d/qsortfilterproxymodelqml.h 2011-07-15 10:35:21 +0000
131+++ libunity-2d-private/Unity2d/qsortfilterproxymodelqml.h 2011-07-27 12:25:44 +0000
132@@ -24,23 +24,36 @@
133 Q_OBJECT
134
135 Q_PROPERTY(QObject* model READ sourceModelQObject WRITE setSourceModelQObject)
136+ Q_PROPERTY(int limit READ limit WRITE setLimit NOTIFY limitChanged)
137+ Q_PROPERTY(int totalCount READ totalCount NOTIFY totalCountChanged)
138+ Q_PROPERTY(int count READ count NOTIFY countChanged)
139
140 public:
141 explicit QSortFilterProxyModelQML(QObject *parent = 0);
142
143 Q_INVOKABLE QVariantMap get(int row);
144 Q_INVOKABLE int count();
145+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
146
147 /* getters */
148 QObject* sourceModelQObject() const;
149+ int limit() const;
150+ int totalCount() const;
151
152 /* setters */
153 void setSourceModelQObject(QObject *model);
154+ void setLimit(int limit);
155
156 Q_SLOT void setRoleNames(const QHash<int,QByteArray> &roleNames);
157
158 Q_SIGNALS:
159+ void limitChanged();
160+ void totalCountChanged();
161+ void countChanged();
162 void roleNamesChanged(const QHash<int,QByteArray> &);
163+
164+private:
165+ int m_limit;
166 };
167
168 #endif // QSORTFILTERPROXYMODELQML_H
169
170=== modified file 'libunity-2d-private/tests/CMakeLists.txt'
171--- libunity-2d-private/tests/CMakeLists.txt 2011-07-12 10:30:50 +0000
172+++ libunity-2d-private/tests/CMakeLists.txt 2011-07-27 12:25:44 +0000
173@@ -40,6 +40,7 @@
174 unity2dtrtest
175 launchermenutest
176 listaggregatormodeltest
177+ qsortfilterproxymodeltest
178 )
179
180 add_custom_target(unity2dtr_po COMMAND
181
182=== added file 'libunity-2d-private/tests/qsortfilterproxymodeltest.cpp'
183--- libunity-2d-private/tests/qsortfilterproxymodeltest.cpp 1970-01-01 00:00:00 +0000
184+++ libunity-2d-private/tests/qsortfilterproxymodeltest.cpp 2011-07-27 12:25:44 +0000
185@@ -0,0 +1,380 @@
186+/*
187+ * Copyright (C) 2011 Canonical, Ltd.
188+ *
189+ * Authors:
190+ * Florian Boucault <florian.boucault@canonical.com>
191+ *
192+ * This program is free software; you can redistribute it and/or modify
193+ * it under the terms of the GNU General Public License as published by
194+ * the Free Software Foundation; version 3.
195+ *
196+ * This program is distributed in the hope that it will be useful,
197+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
198+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
199+ * GNU General Public License for more details.
200+ *
201+ * You should have received a copy of the GNU General Public License
202+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
203+ */
204+
205+// local
206+#include "qsortfilterproxymodelqml.h"
207+
208+// Qt
209+#include <QTest>
210+#include <QSignalSpy>
211+#include <QModelIndex>
212+#include <QAbstractListModel>
213+#include <QDebug>
214+
215+
216+class MockListModel : public QAbstractListModel
217+{
218+ Q_OBJECT
219+
220+public:
221+ MockListModel(QObject* parent = 0)
222+ : QAbstractListModel(parent)
223+ {
224+ }
225+
226+ int rowCount(const QModelIndex& parent = QModelIndex()) const
227+ {
228+ return m_list.size();
229+ }
230+
231+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const
232+ {
233+ Q_UNUSED(role)
234+
235+ if (!index.isValid() || index.row() < 0 || index.row() >= m_list.size()) {
236+ return QVariant();
237+ }
238+ return QVariant(m_list[index.row()]);
239+ }
240+
241+ void setRoleNames(const QHash<int,QByteArray> &roleNames) {
242+ QAbstractListModel::setRoleNames(roleNames);
243+ }
244+
245+ bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) {
246+ beginInsertRows(parent, row, row+count-1);
247+ for (int i=0; i<count; i++) {
248+ m_list.insert(i+row, "test"+i);
249+ }
250+ endInsertRows();
251+ return true;
252+ }
253+
254+ bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) {
255+ beginRemoveRows(parent, row, row+count-1);
256+ for (int i=0; i<count; i++) {
257+ m_list.removeAt(row);
258+ }
259+ endInsertRows();
260+ return true;
261+ }
262+
263+private:
264+ QStringList m_list;
265+};
266+
267+class QSortFilterProxyModelTest : public QObject
268+{
269+ Q_OBJECT
270+
271+private Q_SLOTS:
272+
273+ void initTestCase() {
274+ qRegisterMetaType<QModelIndex>("QModelIndex");
275+ }
276+
277+ void testRoleNamesSetAfter()
278+ {
279+ QSortFilterProxyModelQML proxy;
280+ MockListModel model;
281+ QHash<int, QByteArray> roles;
282+
283+ proxy.setSourceModelQObject(&model);
284+
285+ roles.clear();
286+ roles[0] = "role0";
287+ roles[1] = "role1";
288+ model.setRoleNames(roles);
289+ QCOMPARE(model.roleNames(), proxy.roleNames());
290+ }
291+
292+ void testRoleNamesSetBefore()
293+ {
294+ QSortFilterProxyModelQML proxy;
295+ MockListModel model;
296+ QHash<int, QByteArray> roles;
297+
298+ roles.clear();
299+ roles[0] = "role0";
300+ roles[1] = "role1";
301+ model.setRoleNames(roles);
302+
303+ proxy.setSourceModelQObject(&model);
304+ QCOMPARE(model.roleNames(), proxy.roleNames());
305+ }
306+
307+ void testCountSetAfter()
308+ {
309+ QSortFilterProxyModelQML proxy;
310+ MockListModel model;
311+ model.insertRows(0, 5);
312+
313+ QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged()));
314+
315+ proxy.setSourceModelQObject(&model);
316+ QCOMPARE(proxy.count(), 5);
317+ QVERIFY(spyOnCountChanged.count() >= 1);
318+ }
319+
320+ void testCountInsert()
321+ {
322+ QSortFilterProxyModelQML proxy;
323+ MockListModel model;
324+
325+ proxy.setSourceModelQObject(&model);
326+
327+ QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged()));
328+
329+ model.insertRows(0, 5);
330+ QCOMPARE(proxy.count(), 5);
331+ QCOMPARE(spyOnCountChanged.count(), 1);
332+ }
333+
334+ void testCountRemove()
335+ {
336+ QSortFilterProxyModelQML proxy;
337+ MockListModel model;
338+ model.insertRows(0, 5);
339+
340+ proxy.setSourceModelQObject(&model);
341+
342+ QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged()));
343+
344+ model.removeRows(0, 3);
345+ QCOMPARE(proxy.count(), 2);
346+ QCOMPARE(spyOnCountChanged.count(), 1);
347+ }
348+
349+ void testLimitCount()
350+ {
351+ QSortFilterProxyModelQML proxy;
352+ MockListModel model;
353+
354+ proxy.setSourceModelQObject(&model);
355+ proxy.setLimit(3);
356+
357+ QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged()));
358+
359+ model.insertRows(0, 5);
360+ QCOMPARE(proxy.count(), 3);
361+ QCOMPARE(spyOnCountChanged.count(), 1);
362+ }
363+
364+ void testLimitLesserThanCount()
365+ {
366+ QSortFilterProxyModelQML proxy;
367+ MockListModel model;
368+ QList<QVariant> arguments;
369+ model.insertRows(0, 10);
370+
371+ proxy.setSourceModelQObject(&model);
372+
373+ QSignalSpy spyOnRowsRemoved(&proxy, SIGNAL(rowsRemoved(const QModelIndex &, int, int)));
374+ QSignalSpy spyOnRowsInserted(&proxy, SIGNAL(rowsInserted(const QModelIndex &, int, int)));
375+ QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged()));
376+
377+ proxy.setLimit(5);
378+ QCOMPARE(spyOnRowsRemoved.count(), 1);
379+ QCOMPARE(spyOnRowsInserted.count(), 0);
380+ QCOMPARE(spyOnCountChanged.count(), 1);
381+ arguments = spyOnRowsRemoved.takeFirst();
382+ QCOMPARE(arguments.at(1).toInt(), 5);
383+ QCOMPARE(arguments.at(2).toInt(), 9);
384+ QCOMPARE(proxy.count(), 5);
385+ spyOnRowsRemoved.clear();
386+ spyOnCountChanged.clear();
387+
388+ proxy.setLimit(7);
389+ QCOMPARE(spyOnRowsInserted.count(), 1);
390+ QCOMPARE(spyOnRowsRemoved.count(), 0);
391+ QCOMPARE(spyOnCountChanged.count(), 1);
392+ arguments = spyOnRowsInserted.takeFirst();
393+ QCOMPARE(arguments.at(1).toInt(), 5);
394+ QCOMPARE(arguments.at(2).toInt(), 6);
395+ QCOMPARE(proxy.count(), 7);
396+ spyOnRowsInserted.clear();
397+ spyOnCountChanged.clear();
398+
399+ proxy.setLimit(3);
400+ QCOMPARE(spyOnRowsRemoved.count(), 1);
401+ QCOMPARE(spyOnRowsInserted.count(), 0);
402+ QCOMPARE(spyOnCountChanged.count(), 1);
403+ arguments = spyOnRowsRemoved.takeFirst();
404+ QCOMPARE(arguments.at(1).toInt(), 3);
405+ QCOMPARE(arguments.at(2).toInt(), 6);
406+ QCOMPARE(proxy.count(), 3);
407+ spyOnRowsRemoved.clear();
408+ spyOnCountChanged.clear();
409+ }
410+
411+ void testLimitGreaterThanCount()
412+ {
413+ QSortFilterProxyModelQML proxy;
414+ MockListModel model;
415+ QList<QVariant> arguments;
416+ model.insertRows(0, 5);
417+
418+ proxy.setSourceModelQObject(&model);
419+
420+ QSignalSpy spyOnRowsRemoved(&proxy, SIGNAL(rowsRemoved(const QModelIndex &, int, int)));
421+ QSignalSpy spyOnRowsInserted(&proxy, SIGNAL(rowsInserted(const QModelIndex &, int, int)));
422+ QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged()));
423+
424+ proxy.setLimit(7);
425+ QCOMPARE(spyOnRowsRemoved.count(), 0);
426+ QCOMPARE(spyOnRowsInserted.count(), 0);
427+ QCOMPARE(spyOnCountChanged.count(), 0);
428+ QCOMPARE(proxy.count(), 5);
429+
430+ proxy.setLimit(5);
431+ QCOMPARE(spyOnRowsRemoved.count(), 0);
432+ QCOMPARE(spyOnRowsInserted.count(), 0);
433+ QCOMPARE(spyOnCountChanged.count(), 0);
434+ QCOMPARE(proxy.count(), 5);
435+
436+ proxy.setLimit(3);
437+ QCOMPARE(spyOnRowsInserted.count(), 0);
438+ QCOMPARE(spyOnRowsRemoved.count(), 1);
439+ QCOMPARE(spyOnCountChanged.count(), 1);
440+ arguments = spyOnRowsRemoved.takeFirst();
441+ QCOMPARE(arguments.at(1).toInt(), 3);
442+ QCOMPARE(arguments.at(2).toInt(), 4);
443+ QCOMPARE(proxy.count(), 3);
444+ spyOnRowsRemoved.clear();
445+ spyOnCountChanged.clear();
446+
447+ proxy.setLimit(4);
448+ QCOMPARE(spyOnRowsRemoved.count(), 0);
449+ QCOMPARE(spyOnRowsInserted.count(), 1);
450+ QCOMPARE(spyOnCountChanged.count(), 1);
451+ arguments = spyOnRowsInserted.takeFirst();
452+ QCOMPARE(arguments.at(1).toInt(), 3);
453+ QCOMPARE(arguments.at(2).toInt(), 3);
454+ QCOMPARE(proxy.count(), 4);
455+ spyOnRowsInserted.clear();
456+ spyOnCountChanged.clear();
457+
458+ proxy.setLimit(7);
459+ QCOMPARE(spyOnRowsRemoved.count(), 0);
460+ QCOMPARE(spyOnRowsInserted.count(), 1);
461+ QCOMPARE(spyOnCountChanged.count(), 1);
462+ arguments = spyOnRowsInserted.takeFirst();
463+ QCOMPARE(arguments.at(1).toInt(), 4);
464+ QCOMPARE(arguments.at(2).toInt(), 4);
465+ QCOMPARE(proxy.count(), 5);
466+ spyOnRowsInserted.clear();
467+ spyOnCountChanged.clear();
468+ }
469+
470+ void testLimitMinusOne()
471+ {
472+ QSortFilterProxyModelQML proxy;
473+ MockListModel model;
474+ QList<QVariant> arguments;
475+ model.insertRows(0, 5);
476+
477+ proxy.setSourceModelQObject(&model);
478+
479+ QSignalSpy spyOnRowsRemoved(&proxy, SIGNAL(rowsRemoved(const QModelIndex &, int, int)));
480+ QSignalSpy spyOnRowsInserted(&proxy, SIGNAL(rowsInserted(const QModelIndex &, int, int)));
481+ QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged()));
482+
483+ proxy.setLimit(7);
484+ QCOMPARE(spyOnRowsRemoved.count(), 0);
485+ QCOMPARE(spyOnRowsInserted.count(), 0);
486+ QCOMPARE(spyOnCountChanged.count(), 0);
487+ QCOMPARE(proxy.count(), 5);
488+
489+ proxy.setLimit(-1);
490+ QCOMPARE(spyOnRowsRemoved.count(), 0);
491+ QCOMPARE(spyOnRowsInserted.count(), 0);
492+ QCOMPARE(spyOnCountChanged.count(), 0);
493+ QCOMPARE(proxy.count(), 5);
494+
495+ proxy.setLimit(3);
496+ QCOMPARE(spyOnRowsInserted.count(), 0);
497+ QCOMPARE(spyOnRowsRemoved.count(), 1);
498+ QCOMPARE(spyOnCountChanged.count(), 1);
499+ arguments = spyOnRowsRemoved.takeFirst();
500+ QCOMPARE(arguments.at(1).toInt(), 3);
501+ QCOMPARE(arguments.at(2).toInt(), 4);
502+ QCOMPARE(proxy.count(), 3);
503+ spyOnRowsRemoved.clear();
504+ spyOnCountChanged.clear();
505+
506+ proxy.setLimit(-1);
507+ QCOMPARE(spyOnRowsRemoved.count(), 0);
508+ QCOMPARE(spyOnRowsInserted.count(), 1);
509+ QCOMPARE(spyOnCountChanged.count(), 1);
510+ arguments = spyOnRowsInserted.takeFirst();
511+ QCOMPARE(arguments.at(1).toInt(), 3);
512+ QCOMPARE(arguments.at(2).toInt(), 4);
513+ QCOMPARE(proxy.count(), 5);
514+ spyOnRowsInserted.clear();
515+ spyOnCountChanged.clear();
516+ }
517+
518+ void testLimitInsert() {
519+ QSortFilterProxyModelQML proxy;
520+ MockListModel model;
521+ QList<QVariant> arguments;
522+
523+ proxy.setSourceModelQObject(&model);
524+ proxy.setLimit(7);
525+
526+ QSignalSpy spyOnRowsRemoved(&proxy, SIGNAL(rowsRemoved(const QModelIndex &, int, int)));
527+ QSignalSpy spyOnRowsInserted(&proxy, SIGNAL(rowsInserted(const QModelIndex &, int, int)));
528+ QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged()));
529+
530+ model.insertRows(0, 5);
531+ QCOMPARE(spyOnRowsRemoved.count(), 0);
532+ QCOMPARE(spyOnRowsInserted.count(), 1);
533+ QCOMPARE(spyOnCountChanged.count(), 1);
534+ arguments = spyOnRowsInserted.takeFirst();
535+ QCOMPARE(arguments.at(1).toInt(), 0);
536+ QCOMPARE(arguments.at(2).toInt(), 4);
537+ QCOMPARE(proxy.count(), 5);
538+ spyOnRowsInserted.clear();
539+ spyOnCountChanged.clear();
540+
541+ model.insertRows(2, 2);
542+ QCOMPARE(spyOnRowsRemoved.count(), 0);
543+ QCOMPARE(spyOnRowsInserted.count(), 1);
544+ QCOMPARE(spyOnCountChanged.count(), 1);
545+ arguments = spyOnRowsInserted.takeFirst();
546+ QCOMPARE(arguments.at(1).toInt(), 2);
547+ QCOMPARE(arguments.at(2).toInt(), 3);
548+ QCOMPARE(proxy.count(), 7);
549+ spyOnRowsInserted.clear();
550+ spyOnCountChanged.clear();
551+
552+ /* FIXME: failing case due to QSortFilterProxyModel emitting
553+ rowsInserted/rowsRemoved regardless of the limit */
554+ //model.insertRows(5, 3);
555+ //QCOMPARE(proxy.count(), 7);
556+ //QCOMPARE(spyOnRowsRemoved.count(), 0);
557+ //QCOMPARE(spyOnRowsInserted.count(), 0);
558+ //QCOMPARE(spyOnCountChanged.count(), 0);
559+ }
560+};
561+
562+QTEST_MAIN(QSortFilterProxyModelTest)
563+
564+#include "qsortfilterproxymodeltest.moc"
565+
566
567=== modified file 'places/RendererGrid.qml'
568--- places/RendererGrid.qml 2011-06-23 17:08:53 +0000
569+++ places/RendererGrid.qml 2011-07-27 12:25:44 +0000
570@@ -47,18 +47,18 @@
571 /* Using results.contentHeight produces binding loop warnings and potential
572 rendering issues. We compute the height manually.
573 */
574- /* FIXME: tricking the system by making the delegate of height 0 and with
575- an invisible header is no good: the item in the model still
576- exists and some things such as keyboard selection break.
577+ /* FIXME: tricking the system by making the delegate of height 0 and invisible
578+ is no good: the item in the model still exists and some things
579+ such as keyboard selection break.
580 */
581- height: results.count > 0 ? header.height + results_layout.anchors.topMargin + results.totalHeight : 0
582+ visible: results.model.totalCount > 0
583+ height: visible ? header.height + results_layout.anchors.topMargin + results.totalHeight : 0
584 //Behavior on height {NumberAnimation {duration: 200}}
585
586 GroupHeader {
587 id: header
588
589- visible: results.count > 0
590- availableCount: results.count - results.cellsPerRow
591+ availableCount: results.model.totalCount - results.cellsPerRow
592 folded: parent.folded
593 anchors.top: parent.top
594 anchors.left: parent.left
595@@ -124,9 +124,7 @@
596 width: flickable.width
597 height: Math.min(totalHeight, flickable.height)
598
599- /* Only display one line of items when folded */
600- property int displayedCount: folded ? cellsPerRow : count
601- property int totalHeight: results.cellHeight*Math.ceil(displayedCount/cellsPerRow)
602+ property int totalHeight: results.cellHeight*Math.ceil(count/cellsPerRow)
603
604 minHorizontalSpacing: renderer.horizontalSpacing
605 minVerticalSpacing: renderer.verticalSpacing
606@@ -168,7 +166,11 @@
607 }
608 }
609
610- model: renderer.model
611+ /* Only display one line of items when folded */
612+ model: SortFilterProxyModel {
613+ model: renderer.model != undefined ? renderer.model : null
614+ limit: folded ? results.cellsPerRow : -1
615+ }
616 }
617 }
618 }

Subscribers

People subscribed via source and target branches