summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/itemmodels/qfilesystemmodel.cpp7
-rw-r--r--tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp15
2 files changed, 20 insertions, 2 deletions
diff --git a/src/gui/itemmodels/qfilesystemmodel.cpp b/src/gui/itemmodels/qfilesystemmodel.cpp
index 70c274b816..e0274e5fef 100644
--- a/src/gui/itemmodels/qfilesystemmodel.cpp
+++ b/src/gui/itemmodels/qfilesystemmodel.cpp
@@ -391,8 +391,11 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS
if (absolutePath.endsWith(QLatin1Char('/')))
trailingSeparator = QLatin1String("\\");
int r = 0;
- QFileSystemModelPrivate::QFileSystemNode *rootNode = const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
- if (!root.children.contains(host.toLower())) {
+ auto rootNode = const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
+ auto it = root.children.constFind(host);
+ if (it != root.children.cend()) {
+ host = it.key(); // Normalize case for lookup in visibleLocation()
+ } else {
if (pathElements.count() == 1 && !absolutePath.endsWith(QLatin1Char('/')))
return rootNode;
QFileInfo info(host);
diff --git a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
index e814e79dbe..4fe998f43e 100644
--- a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -226,6 +226,21 @@ void tst_QFileSystemModel::rootPath()
QCOMPARE(rootChanged.count(), oldCount + 1);
QCOMPARE(model->rootDirectory().absolutePath(), newdir.path());
}
+
+#ifdef Q_OS_WIN
+ // check case insensitive root node on windows, tests QTBUG-71701
+ QModelIndex index = model->setRootPath(QString("\\\\localhost\\c$"));
+ QVERIFY(index.isValid());
+ QCOMPARE(model->rootPath(), QString("//localhost/c$"));
+
+ index = model->setRootPath(QString("\\\\localhost\\C$"));
+ QVERIFY(index.isValid());
+ QCOMPARE(model->rootPath(), QString("//localhost/C$"));
+
+ index = model->setRootPath(QString("\\\\LOCALHOST\\C$"));
+ QVERIFY(index.isValid());
+ QCOMPARE(model->rootPath(), QString("//LOCALHOST/C$"));
+#endif
}
void tst_QFileSystemModel::readOnly()