diff options
author | Sergio Martins <sergio.martins@kdab.com> | 2013-03-27 18:30:44 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-28 16:06:45 (GMT) |
commit | 7f1197a689deae502129148be94b63c246962b8f (patch) | |
tree | 3ba8a60a633fe24f4e301ccba920038351abf62b /src/gui | |
parent | ac69080efd0f0efea50e08b8f2f9550befd3b7ae (diff) | |
download | Qt-7f1197a689deae502129148be94b63c246962b8f.zip Qt-7f1197a689deae502129148be94b63c246962b8f.tar.gz Qt-7f1197a689deae502129148be94b63c246962b8f.tar.bz2 |
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')
-rw-r--r-- | src/gui/dialogs/qfileinfogatherer.cpp | 2 | ||||
-rw-r--r-- | src/gui/dialogs/qfileinfogatherer_p.h | 8 | ||||
-rw-r--r-- | src/gui/dialogs/qfilesystemmodel.cpp | 3 | ||||
-rw-r--r-- | src/gui/dialogs/qfilesystemmodel_p.h | 2 |
4 files changed, 11 insertions, 4 deletions
diff --git a/src/gui/dialogs/qfileinfogatherer.cpp b/src/gui/dialogs/qfileinfogatherer.cpp index d58a183..a4b1e13 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 539f52d..5f89ddd 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 8007c4e..4e9285b 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 7cc8672..0b929f5 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(); } |