diff options
author | Alberto Mardegan <info@mardy.it> | 2012-12-26 13:59:52 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-06-25 20:53:52 +0200 |
commit | 6ad5400c54302ee5e099e478e91de53386b62902 (patch) | |
tree | b93b4141d6d1f527c6cbab0fd3bdcec4af2c1c5c /tests/auto/qml/qquickfolderlistmodel | |
parent | 0f97dd8b3d86d60897fed0e87d95de2e3ed59206 (diff) |
Add "showFiles" property to FolderListModel
This property, if set to "false", causes the FolderListModel not to show
regular files. This can be useful when someone wants to list only the
directories; for instance, one can have a ListView showing only the
directories (with "showDirs: true" and "showFiles: false") and another
for showing the directory contents ("showFiles: true" and "showDirs:
false").
Since by default this property is "true", the behavior of applications
who don't use this property is unchanged.
Change-Id: I6eaa9c4a6a582ea81fa07bad129a4c9b15fdcaea
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'tests/auto/qml/qquickfolderlistmodel')
-rw-r--r-- | tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp index b845faca7d..9308bc6f40 100644 --- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp +++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp @@ -71,6 +71,7 @@ public slots: private slots: void basicProperties(); + void showFiles(); void resetFiltering(); void refresh(); #if defined (Q_OS_WIN) && !defined (Q_OS_WINCE) @@ -121,6 +122,7 @@ void tst_qquickfolderlistmodel::basicProperties() QCOMPARE(flm->property("sortField").toInt(), int(Name)); QCOMPARE(flm->property("nameFilters").toStringList(), QStringList() << "*.qml"); QCOMPARE(flm->property("sortReversed").toBool(), false); + QCOMPARE(flm->property("showFiles").toBool(), true); QCOMPARE(flm->property("showDirs").toBool(), true); QCOMPARE(flm->property("showDotAndDotDot").toBool(), false); QCOMPARE(flm->property("showOnlyReadable").toBool(), false); @@ -131,6 +133,23 @@ void tst_qquickfolderlistmodel::basicProperties() QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile("")); } +void tst_qquickfolderlistmodel::showFiles() +{ + QQmlComponent component(&engine, testFileUrl("basic.qml")); + checkNoErrors(component); + + QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create()); + QVERIFY(flm != 0); + + flm->setProperty("folder", dataDirectoryUrl()); + QTRY_COMPARE(flm->property("count").toInt(), 5); // wait for refresh + QCOMPARE(flm->property("showFiles").toBool(), true); + + flm->setProperty("showFiles", false); + QCOMPARE(flm->property("showFiles").toBool(), false); + QTRY_COMPARE(flm->property("count").toInt(), 1); // wait for refresh +} + void tst_qquickfolderlistmodel::resetFiltering() { // see QTBUG-17837 |