diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp index e8da8aa651..0f12c2b80e 100644 --- a/src/widgets/dialogs/qfileinfogatherer.cpp +++ b/src/widgets/dialogs/qfileinfogatherer.cpp @@ -238,7 +238,7 @@ QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const #endif #ifdef Q_OS_WIN - if (fileInfo.isSymLink() && m_resolveSymlinks) { + if (m_resolveSymlinks && info.isSymLink(/* ignoreNtfsSymLinks = */ true)) { QFileInfo resolvedInfo(fileInfo.symLinkTarget()); resolvedInfo = resolvedInfo.canonicalFilePath(); if (resolvedInfo.exists()) { diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h index 0c4e644e40..447ee78edc 100644 --- a/src/widgets/dialogs/qfileinfogatherer_p.h +++ b/src/widgets/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_OS_WIN + return !mFileInfo.suffix().compare(QLatin1String("lnk"), Qt::CaseInsensitive); +#endif + } return mFileInfo.isSymLink(); } diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 5bf5356d89..a4009de68d 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -800,7 +800,7 @@ QString QFileSystemModelPrivate::name(const QModelIndex &index) const if (!index.isValid()) return QString(); QFileSystemNode *dirNode = node(index); - if (dirNode->isSymLink() && fileInfoGatherer.resolveSymlinks()) { + if (fileInfoGatherer.resolveSymlinks() && dirNode->isSymLink(/* ignoreNtfsSymLinks = */ true)) { QString fullPath = QDir::fromNativeSeparators(filePath(index)); if (resolvedSymLinks.contains(fullPath)) return resolvedSymLinks[fullPath]; diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h index d61936d545..663be3d933 100644 --- a/src/widgets/dialogs/qfilesystemmodel_p.h +++ b/src/widgets/dialogs/qfilesystemmodel_p.h @@ -116,7 +116,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(); }