aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qquickfolderlistmodel
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2014-03-04 16:05:50 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-18 10:18:57 +0100
commita412d0aa7e98d98c6f8ee82050766cc8fd6f7903 (patch)
treec02d48190c8486a2cc5113f4786cf167a830bfda /tests/auto/qml/qquickfolderlistmodel
parentc3fbec3ab955eb2b771a6a54d2910d25a1c7277c (diff)
FolderListModel: pessimize change signals when the filter changes
FileInfoThread doesn't have separate signals for insertions, deletions and updates, so QQuickFolderListModel shouldn't make an assumption that if the list got bigger, an insertion was the only thing that happened. Task-number: QTBUG-36576 Change-Id: Ibb02d64e1645dd6df231d28a93e424aaad0effff Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'tests/auto/qml/qquickfolderlistmodel')
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test1.html1
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test2.html1
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp47
3 files changed, 38 insertions, 11 deletions
diff --git a/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test1.html b/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test1.html
new file mode 100644
index 0000000000..4da4639310
--- /dev/null
+++ b/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test1.html
@@ -0,0 +1 @@
+<P>This file contains some HTML.</P>
diff --git a/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test2.html b/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test2.html
new file mode 100644
index 0000000000..4da4639310
--- /dev/null
+++ b/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test2.html
@@ -0,0 +1 @@
+<P>This file contains some HTML.</P>
diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
index a6e6345223..4296ae4f09 100644
--- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
+++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
@@ -73,6 +73,7 @@ private slots:
void basicProperties();
void showFiles();
void resetFiltering();
+ void nameFilters();
void refresh();
void cdUp();
#ifdef Q_OS_WIN32
@@ -169,26 +170,50 @@ void tst_qquickfolderlistmodel::resetFiltering()
QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
QVERIFY(flm != 0);
+ flm->setProperty("folder", testFileUrl("resetfiltering"));
+ // _q_directoryUpdated may be triggered if model was empty before, but there won't be a rowsRemoved signal
+ QTRY_COMPARE(flm->property("count").toInt(),3); // all files visible
+
+ flm->setProperty("folder", testFileUrl("resetfiltering/innerdir"));
+ // _q_directoryChanged is triggered so it's a total model refresh
+ QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test2.txt" visible
+
+ flm->setProperty("folder", testFileUrl("resetfiltering"));
+ // _q_directoryChanged is triggered so it's a total model refresh
+ QTRY_COMPARE(flm->property("count").toInt(),3); // all files visible
+}
+
+void tst_qquickfolderlistmodel::nameFilters()
+{
+ // see QTBUG-36576
+ QQmlComponent component(&engine, testFileUrl("resetFiltering.qml"));
+ checkNoErrors(component);
+
+ QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
+ QVERIFY(flm != 0);
+
connect(flm, SIGNAL(rowsRemoved(QModelIndex,int,int)),
this, SLOT(removed(QModelIndex,int,int)));
+ QTRY_VERIFY(flm->rowCount() > 0);
flm->setProperty("folder", testFileUrl("resetfiltering"));
- QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test.txt" visible
+ QTRY_COMPARE(flm->property("count").toInt(),3); // all files visible
+
int count = flm->rowCount();
+ flm->setProperty("nameFilters", QStringList() << "*.txt");
+ // _q_directoryUpdated triggered with range 0:1
+ QTRY_COMPARE(flm->property("count").toInt(),1);
+ QCOMPARE(flm->data(flm->index(0),FileNameRole), QVariant("test.txt"));
QCOMPARE(removeStart, 0);
QCOMPARE(removeEnd, count-1);
- flm->setProperty("folder", testFileUrl("resetfiltering/innerdir"));
- QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test2.txt" visible
- count = flm->rowCount();
- QCOMPARE(removeStart, 0);
- QCOMPARE(removeEnd, count-1);
+ flm->setProperty("nameFilters", QStringList() << "*.html");
+ QTRY_COMPARE(flm->property("count").toInt(),2);
+ QCOMPARE(flm->data(flm->index(0),FileNameRole), QVariant("test1.html"));
+ QCOMPARE(flm->data(flm->index(1),FileNameRole), QVariant("test2.html"));
- flm->setProperty("folder", testFileUrl("resetfiltering"));
- QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test.txt" visible
- count = flm->rowCount();
- QCOMPARE(removeStart, 0);
- QCOMPARE(removeEnd, count-1);
+ flm->setProperty("nameFilters", QStringList());
+ QTRY_COMPARE(flm->property("count").toInt(),3); // all files visible
}
void tst_qquickfolderlistmodel::refresh()