aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorJoni Poikelin <joni.poikelin@theqtcompany.com>2015-10-09 12:45:43 +0300
committerJoni Poikelin <joni.poikelin@theqtcompany.com>2015-10-12 09:53:54 +0000
commit60866c99bc908a5c5a2a9cdfa74b00d692233f2f (patch)
treeb2a362c54f9f3f47fc336f8056f4cb8946095ffc /src/imports
parentff1264cd6f48cd2bbf61e04a454c7ccccefa40d9 (diff)
Add caseSensitive property to FolderListModel
Allows controlling case sensitivity of nameFilters Task-number: QTBUG-45566 Change-Id: Iab3bdd4cbaee59e16fafb9d153f51b35b22a822a Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/folderlistmodel/fileinfothread.cpp14
-rw-r--r--src/imports/folderlistmodel/fileinfothread_p.h2
-rw-r--r--src/imports/folderlistmodel/plugin.cpp1
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.cpp27
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.h3
5 files changed, 44 insertions, 3 deletions
diff --git a/src/imports/folderlistmodel/fileinfothread.cpp b/src/imports/folderlistmodel/fileinfothread.cpp
index ebdfba42a8..731eb45460 100644
--- a/src/imports/folderlistmodel/fileinfothread.cpp
+++ b/src/imports/folderlistmodel/fileinfothread.cpp
@@ -52,7 +52,8 @@ FileInfoThread::FileInfoThread(QObject *parent)
showDirsFirst(false),
showDotAndDotDot(false),
showHidden(false),
- showOnlyReadable(false)
+ showOnlyReadable(false),
+ caseSensitive(true)
{
#ifndef QT_NO_FILESYSTEMWATCHER
watcher = new QFileSystemWatcher(this);
@@ -190,6 +191,14 @@ void FileInfoThread::setShowOnlyReadable(bool on)
condition.wakeAll();
}
+void FileInfoThread::setCaseSensitive(bool on)
+{
+ QMutexLocker locker(&mutex);
+ caseSensitive = on;
+ folderUpdate = true;
+ condition.wakeAll();
+}
+
#ifndef QT_NO_FILESYSTEMWATCHER
void FileInfoThread::updateFile(const QString &path)
{
@@ -228,7 +237,8 @@ void FileInfoThread::run()
void FileInfoThread::getFileInfos(const QString &path)
{
QDir::Filters filter;
- filter = QDir::CaseSensitive;
+ if (caseSensitive)
+ filter = QDir::CaseSensitive;
if (showFiles)
filter = filter | QDir::Files;
if (showDirs)
diff --git a/src/imports/folderlistmodel/fileinfothread_p.h b/src/imports/folderlistmodel/fileinfothread_p.h
index ee325fa50b..6a3e71b81c 100644
--- a/src/imports/folderlistmodel/fileinfothread_p.h
+++ b/src/imports/folderlistmodel/fileinfothread_p.h
@@ -68,6 +68,7 @@ public:
void setShowDotAndDotDot(bool on);
void setShowHidden(bool on);
void setShowOnlyReadable(bool on);
+ void setCaseSensitive(bool on);
public Q_SLOTS:
#ifndef QT_NO_FILESYSTEMWATCHER
@@ -102,6 +103,7 @@ private:
bool showDotAndDotDot;
bool showHidden;
bool showOnlyReadable;
+ bool caseSensitive;
};
#endif // FILEINFOTHREAD_P_H
diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp
index a2536bdc7d..7280fcd1dc 100644
--- a/src/imports/folderlistmodel/plugin.cpp
+++ b/src/imports/folderlistmodel/plugin.cpp
@@ -52,6 +52,7 @@ public:
qmlRegisterType<QQuickFolderListModel>(uri,1,0,"FolderListModel");
qmlRegisterType<QQuickFolderListModel>(uri,2,0,"FolderListModel");
qmlRegisterType<QQuickFolderListModel,1>(uri,2,1,"FolderListModel");
+ qmlRegisterType<QQuickFolderListModel,2>(uri,2,2,"FolderListModel");
#endif
}
};
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
index 0f4a5bda54..6c9b3eaf98 100644
--- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
@@ -49,7 +49,7 @@ public:
: q_ptr(q),
sortField(QQuickFolderListModel::Name), sortReversed(false), showFiles(true),
showDirs(true), showDirsFirst(false), showDotAndDotDot(false), showOnlyReadable(false),
- showHidden(false)
+ showHidden(false), caseSensitive(true)
{
nameFilters << QLatin1String("*");
}
@@ -70,6 +70,7 @@ public:
bool showDotAndDotDot;
bool showOnlyReadable;
bool showHidden;
+ bool caseSensitive;
~QQuickFolderListModelPrivate() {}
void init();
@@ -762,6 +763,30 @@ void QQuickFolderListModel::setShowOnlyReadable(bool on)
}
/*!
+ * \qmlproperty bool FolderListModel::caseSensitive
+ * \since 5.7
+ *
+ * Use case sensitive pattern matching.
+ *
+ * By default, this property is true.
+ *
+ */
+bool QQuickFolderListModel::caseSensitive() const
+{
+ Q_D(const QQuickFolderListModel);
+ return d->caseSensitive;
+}
+
+void QQuickFolderListModel::setCaseSensitive(bool on)
+{
+ Q_D(QQuickFolderListModel);
+
+ if (on != d->caseSensitive) {
+ d->fileInfoThread.setCaseSensitive(on);
+ }
+}
+
+/*!
\qmlmethod var FolderListModel::get(int index, string property)
Get the folder property for the given index. The following properties
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.h b/src/imports/folderlistmodel/qquickfolderlistmodel.h
index fcfec56c87..4b540742b4 100644
--- a/src/imports/folderlistmodel/qquickfolderlistmodel.h
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.h
@@ -67,6 +67,7 @@ class QQuickFolderListModel : public QAbstractListModel, public QQmlParserStatus
Q_PROPERTY(bool showDotAndDotDot READ showDotAndDotDot WRITE setShowDotAndDotDot)
Q_PROPERTY(bool showHidden READ showHidden WRITE setShowHidden REVISION 1)
Q_PROPERTY(bool showOnlyReadable READ showOnlyReadable WRITE setShowOnlyReadable)
+ Q_PROPERTY(bool caseSensitive READ caseSensitive WRITE setCaseSensitive REVISION 2)
Q_PROPERTY(int count READ count NOTIFY countChanged)
//![class props]
@@ -128,6 +129,8 @@ public:
void setShowHidden(bool on);
bool showOnlyReadable() const;
void setShowOnlyReadable(bool on);
+ bool caseSensitive() const;
+ void setCaseSensitive(bool on);
//![prop funcs]
Q_INVOKABLE bool isFolder(int index) const;