summaryrefslogtreecommitdiffstats
path: root/src/gui/dialogs
diff options
context:
space:
mode:
authorSergio Martins <sergio.martins@kdab.com>2013-03-27 18:30:44 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-28 17:06:45 +0100
commit7f1197a689deae502129148be94b63c246962b8f (patch)
tree3ba8a60a633fe24f4e301ccba920038351abf62b /src/gui/dialogs
parentac69080efd0f0efea50e08b8f2f9550befd3b7ae (diff)
Windows: Fix the last file dialog bottleneck.
Went from taking 30 seconds to 2 seconds, on a SDCard with 10k files. Windows file dialog does not resolve NTFS symlinks, it just shows an empty icon, and the link name, not the target. This allows for a big performance gain by reducing the number of calls to GetFileAttributesEx() by checking the extension directly. This also fixes the problems with the native file dialog, which for some reason, is creating a QFileSystemModel too. Task-number: QTBUG-13182 (cherry picked from commit 51f00deffac49c4277425837f0132b0c721bb689) Change-Id: If7bd63d68e1870c5e48907ae79f4c4bdc6972b00 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/gui/dialogs')
-rw-r--r--src/gui/dialogs/qfileinfogatherer.cpp2
-rw-r--r--src/gui/dialogs/qfileinfogatherer_p.h8
-rw-r--r--src/gui/dialogs/qfilesystemmodel.cpp3
-rw-r--r--src/gui/dialogs/qfilesystemmodel_p.h2
4 files changed, 11 insertions, 4 deletions
diff --git a/src/gui/dialogs/qfileinfogatherer.cpp b/src/gui/dialogs/qfileinfogatherer.cpp
index d58a183aef..a4b1e13a11 100644
--- a/src/gui/dialogs/qfileinfogatherer.cpp
+++ b/src/gui/dialogs/qfileinfogatherer.cpp
@@ -248,7 +248,7 @@ QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const
#endif
#endif
- if (m_resolveSymlinks && fileInfo.isSymLink()) {
+ if (m_resolveSymlinks && info.isSymLink(/* ignoreNtfsSymLinks = */ true)) {
QFileInfo resolvedInfo(fileInfo.symLinkTarget());
resolvedInfo = resolvedInfo.canonicalFilePath();
if (resolvedInfo.exists()) {
diff --git a/src/gui/dialogs/qfileinfogatherer_p.h b/src/gui/dialogs/qfileinfogatherer_p.h
index 539f52dd94..5f89ddd0f4 100644
--- a/src/gui/dialogs/qfileinfogatherer_p.h
+++ b/src/gui/dialogs/qfileinfogatherer_p.h
@@ -108,7 +108,13 @@ public:
return QExtendedInformation::System;
}
- bool isSymLink() const {
+ bool isSymLink(bool ignoreNtfsSymLinks = false) const
+ {
+ if (ignoreNtfsSymLinks) {
+#ifdef Q_WS_WIN
+ return !mFileInfo.suffix().compare(QLatin1String("lnk"), Qt::CaseInsensitive);
+#endif
+ }
return mFileInfo.isSymLink();
}
diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp
index 8007c4e45d..4e9285bd3a 100644
--- a/src/gui/dialogs/qfilesystemmodel.cpp
+++ b/src/gui/dialogs/qfilesystemmodel.cpp
@@ -803,7 +803,8 @@ QString QFileSystemModelPrivate::name(const QModelIndex &index) const
if (!index.isValid())
return QString();
QFileSystemNode *dirNode = node(index);
- if (fileInfoGatherer.resolveSymlinks() && !resolvedSymLinks.isEmpty() && dirNode->isSymLink()) {
+ if (fileInfoGatherer.resolveSymlinks() && !resolvedSymLinks.isEmpty() &&
+ dirNode->isSymLink(/* ignoreNtfsSymLinks = */ true)) {
QString fullPath = QDir::fromNativeSeparators(filePath(index));
if (resolvedSymLinks.contains(fullPath))
return resolvedSymLinks[fullPath];
diff --git a/src/gui/dialogs/qfilesystemmodel_p.h b/src/gui/dialogs/qfilesystemmodel_p.h
index 7cc8672068..0b929f51ea 100644
--- a/src/gui/dialogs/qfilesystemmodel_p.h
+++ b/src/gui/dialogs/qfilesystemmodel_p.h
@@ -118,7 +118,7 @@ public:
inline bool isFile() const { if (info) return info->isFile(); return true; }
inline bool isSystem() const { if (info) return info->isSystem(); return true; }
inline bool isHidden() const { if (info) return info->isHidden(); return false; }
- inline bool isSymLink() const { if (info) return info->isSymLink(); return false; }
+ inline bool isSymLink(bool ignoreNtfsSymLinks = false) const { return info && info->isSymLink(ignoreNtfsSymLinks); }
inline bool caseSensitive() const { if (info) return info->isCaseSensitive(); return false; }
inline QIcon icon() const { if (info) return info->icon; return QIcon(); }