diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/folderlistmodel/fileinfothread.cpp | 1 | ||||
-rw-r--r-- | src/imports/folderlistmodel/plugin.cpp | 3 | ||||
-rw-r--r-- | src/imports/folderlistmodel/qquickfolderlistmodel.cpp | 30 | ||||
-rw-r--r-- | src/imports/folderlistmodel/qquickfolderlistmodel.h | 3 |
4 files changed, 36 insertions, 1 deletions
diff --git a/src/imports/folderlistmodel/fileinfothread.cpp b/src/imports/folderlistmodel/fileinfothread.cpp index 5b44ed012f..a006f659c9 100644 --- a/src/imports/folderlistmodel/fileinfothread.cpp +++ b/src/imports/folderlistmodel/fileinfothread.cpp @@ -135,6 +135,7 @@ void FileInfoThread::setSortFlags(QDir::SortFlags flags) QMutexLocker locker(&mutex); sortFlags = flags; sortUpdate = true; + needUpdate = true; condition.wakeAll(); } diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp index 7089fed4ad..31cd793737 100644 --- a/src/imports/folderlistmodel/plugin.cpp +++ b/src/imports/folderlistmodel/plugin.cpp @@ -65,6 +65,9 @@ public: // revision in Qt 5.11: added status property qmlRegisterType<QQuickFolderListModel,11>(uri, 2, 11, "FolderListModel"); + + // revision in Qt 5.12: added sortCaseSensitive property + qmlRegisterType<QQuickFolderListModel,12>(uri, 2, 12, "FolderListModel"); } }; //![class decl] diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp index 66d9e7ae46..3c00a76cc5 100644 --- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp @@ -55,7 +55,9 @@ public: : q_ptr(q), sortField(QQuickFolderListModel::Name), sortReversed(false), showFiles(true), showDirs(true), showDirsFirst(false), showDotAndDotDot(false), showOnlyReadable(false), - showHidden(false), caseSensitive(true), status(QQuickFolderListModel::Null) + showHidden(false), caseSensitive(true), sortCaseSensitive(true), + status(QQuickFolderListModel::Null) + { nameFilters << QLatin1String("*"); } @@ -77,6 +79,7 @@ public: bool showOnlyReadable; bool showHidden; bool caseSensitive; + bool sortCaseSensitive; QQuickFolderListModel::Status status; ~QQuickFolderListModelPrivate() {} @@ -140,6 +143,8 @@ void QQuickFolderListModelPrivate::updateSorting() if (sortReversed) flags |= QDir::Reversed; + if (!sortCaseSensitive) + flags |= QDir::IgnoreCase; fileInfoThread.setSortFlags(flags); } @@ -856,6 +861,29 @@ QQuickFolderListModel::Status QQuickFolderListModel::status() const } /*! + \qmlproperty bool FolderListModel::sortCaseSensitive + \since 5.12 + + If set to true, the sort is case sensitive. This property is true by default. +*/ + +bool QQuickFolderListModel::sortCaseSensitive() const +{ + Q_D(const QQuickFolderListModel); + return d->sortCaseSensitive; +} + +void QQuickFolderListModel::setSortCaseSensitive(bool on) +{ + Q_D(QQuickFolderListModel); + + if (on != d->sortCaseSensitive) { + d->sortCaseSensitive = on; + d->updateSorting(); + } +} + +/*! \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 a449f0dd0f..cc03ff441b 100644 --- a/src/imports/folderlistmodel/qquickfolderlistmodel.h +++ b/src/imports/folderlistmodel/qquickfolderlistmodel.h @@ -76,6 +76,7 @@ class QQuickFolderListModel : public QAbstractListModel, public QQmlParserStatus Q_PROPERTY(bool caseSensitive READ caseSensitive WRITE setCaseSensitive REVISION 2) Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(Status status READ status NOTIFY statusChanged REVISION 11) + Q_PROPERTY(bool sortCaseSensitive READ sortCaseSensitive WRITE setSortCaseSensitive REVISION 12) //![class props] //![abslistmodel] @@ -142,6 +143,8 @@ public: enum Status { Null, Ready, Loading }; Q_ENUM(Status) Status status() const; + bool sortCaseSensitive() const; + void setSortCaseSensitive(bool on); //![prop funcs] Q_INVOKABLE bool isFolder(int index) const; |