aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2018-10-11 14:47:54 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2018-10-19 12:03:39 +0000
commit4d8cdc7d69594602246807097b92f72b42f4f6e9 (patch)
treee7dcac903bf1ab1627dc1ad43552a6b1bf1ca58f /src/imports/folderlistmodel/qquickfolderlistmodel.cpp
parenta9559a8b84ec221550512fd7ff50f6fc5a569c59 (diff)
Add sortCaseSensitive property so the sorting can ignore the case
Change-Id: Id308272cc59eca8c95f1386db8cd64f266124579 Fixes: QTBUG-48757 Fixes: QTBUG-70212 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/imports/folderlistmodel/qquickfolderlistmodel.cpp')
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.cpp30
1 files changed, 29 insertions, 1 deletions
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