aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWang Chuan <ouchuanm@outlook.com>2019-09-08 01:40:19 +0800
committerWang Chuan <ouchuanm@outlook.com>2019-09-11 07:50:54 +0000
commit2b566231a6e35ee1646754cee09b30fc99240a80 (patch)
treef10e1a863d41f3cac9e26337eb0c0e1ce19fc5d8
parent264766764e9d0ddf25442a27b900287623826eb7 (diff)
QQuickFolderListModel: make sure properties' values can be update
There are some properties in FolderListModel neglect to update their values, although the new values are passed to the thread which does the real work [ChangeLog][QtQuick][QQuickFolderListModel] update the values of some properties when setting new values to them Fixes: QTBUG-77965 Change-Id: I77db3388cee569479459deaa2e19546a77da6178 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.cpp4
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp42
2 files changed, 46 insertions, 0 deletions
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
index affb1e9fe2..49836ad10c 100644
--- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
@@ -731,6 +731,7 @@ void QQuickFolderListModel::setShowDotAndDotDot(bool on)
if (on != d->showDotAndDotDot) {
d->fileInfoThread.setShowDotAndDotDot(on);
+ d->showDotAndDotDot = on;
}
}
@@ -756,6 +757,7 @@ void QQuickFolderListModel::setShowHidden(bool on)
if (on != d->showHidden) {
d->fileInfoThread.setShowHidden(on);
+ d->showHidden = on;
}
}
@@ -781,6 +783,7 @@ void QQuickFolderListModel::setShowOnlyReadable(bool on)
if (on != d->showOnlyReadable) {
d->fileInfoThread.setShowOnlyReadable(on);
+ d->showOnlyReadable = on;
}
}
@@ -805,6 +808,7 @@ void QQuickFolderListModel::setCaseSensitive(bool on)
if (on != d->caseSensitive) {
d->fileInfoThread.setCaseSensitive(on);
+ d->caseSensitive = on;
}
}
diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
index b7600351b7..ae99e35467 100644
--- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
+++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
@@ -75,6 +75,7 @@ private slots:
void introspectQrc();
void sortCaseSensitive_data();
void sortCaseSensitive();
+ void updateProperties();
private:
void checkNoErrors(const QQmlComponent& component);
QQmlEngine engine;
@@ -425,6 +426,47 @@ void tst_qquickfolderlistmodel::sortCaseSensitive()
QTRY_COMPARE(flm->data(flm->index(i),FileNameRole).toString(), expectedOrder.at(i));
}
+void tst_qquickfolderlistmodel::updateProperties()
+{
+ QQmlComponent component(&engine, testFileUrl("basic.qml"));
+ checkNoErrors(component);
+
+ QObject *folderListModel = component.create();
+ QVERIFY(folderListModel);
+
+ QVariant caseSensitive = folderListModel->property("caseSensitive");
+ QVERIFY(caseSensitive.isValid());
+ QCOMPARE(caseSensitive.toBool(), true);
+ folderListModel->setProperty("caseSensitive", false);
+ caseSensitive = folderListModel->property("caseSensitive");
+ QVERIFY(caseSensitive.isValid());
+ QCOMPARE(caseSensitive.toBool(), false);
+
+ QVariant showOnlyReadable = folderListModel->property("showOnlyReadable");
+ QVERIFY(showOnlyReadable.isValid());
+ QCOMPARE(showOnlyReadable.toBool(), false);
+ folderListModel->setProperty("showOnlyReadable", true);
+ showOnlyReadable = folderListModel->property("showOnlyReadable");
+ QVERIFY(showOnlyReadable.isValid());
+ QCOMPARE(showOnlyReadable.toBool(), true);
+
+ QVariant showDotAndDotDot = folderListModel->property("showDotAndDotDot");
+ QVERIFY(showDotAndDotDot.isValid());
+ QCOMPARE(showDotAndDotDot.toBool(), false);
+ folderListModel->setProperty("showDotAndDotDot", true);
+ showDotAndDotDot = folderListModel->property("showDotAndDotDot");
+ QVERIFY(showDotAndDotDot.isValid());
+ QCOMPARE(showDotAndDotDot.toBool(), true);
+
+ QVariant showHidden = folderListModel->property("showHidden");
+ QVERIFY(showHidden.isValid());
+ QCOMPARE(showHidden.toBool(), false);
+ folderListModel->setProperty("showHidden", true);
+ showHidden = folderListModel->property("showHidden");
+ QVERIFY(showHidden.isValid());
+ QCOMPARE(showHidden.toBool(), true);
+}
+
QTEST_MAIN(tst_qquickfolderlistmodel)
#include "tst_qquickfolderlistmodel.moc"