diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-06-12 15:31:53 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-07-03 12:44:00 +0000 |
commit | f2df5c64bde5a3837048347b18c246e674de5caa (patch) | |
tree | 5f18d27e55a2e1c6e2c7eb7f4bc7e7d07974a477 /src/widgets/itemviews/qdirmodel.cpp | |
parent | 00b8050d68c337f02713d3c353ded9de094eda79 (diff) |
QFileSystemEntry: Export static helper function checking for the root path
This provides a helper function which does the check on the string.
QFileInfo::isRoot() in addition checks for the existence of
the directory, which can cause hangs with network drives.
Use the new function in appropriate places in QtWidgets.
Task-number: QTBUG-6039
Change-Id: I54d0d860713e82b28fa4069a5345b042337f9c52
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/widgets/itemviews/qdirmodel.cpp')
-rw-r--r-- | src/widgets/itemviews/qdirmodel.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index 95e6a1840d..5526da8509 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -52,6 +52,7 @@ #include <qstyle.h> #include <qapplication.h> #include <private/qabstractitemmodel_p.h> +#include <private/qfilesystementry_p.h> #include <qdebug.h> #include <stack> @@ -1104,8 +1105,9 @@ QString QDirModel::fileName(const QModelIndex &index) const if (!d->indexValid(index)) return QString(); QFileInfo info = fileInfo(index); - if (info.isRoot()) - return info.absoluteFilePath(); + const QString &path = info.absoluteFilePath(); + if (QFileSystemEntry::isRootPath(path)) + return path; if (d->resolveSymlinks && info.isSymLink()) info = d->resolvedInfo(info); return info.fileName(); @@ -1280,8 +1282,8 @@ QString QDirModelPrivate::name(const QModelIndex &index) const { const QDirNode *n = node(index); const QFileInfo info = n->info; - if (info.isRoot()) { - QString name = info.absoluteFilePath(); + QString name = info.absoluteFilePath(); + if (QFileSystemEntry::isRootPath(name)) { #if defined(Q_OS_WIN) if (name.startsWith(QLatin1Char('/'))) // UNC host return info.fileName(); |