diff options
author | Glenn Watson <glenn.watson@nokia.com> | 2012-07-26 15:00:28 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-31 07:44:12 +0200 |
commit | 9b671727010ccc45cc51840630b159cd34dd983d (patch) | |
tree | 8d316bafd6037e4bd3eda0be657e5811132f41ae /src/imports | |
parent | f37d7020f986a6e0b3c6d7e9c07ccac2a858b304 (diff) |
Fix folder list model when changing drives on Windows.
The folder list model implementation drops drive letters when
changing folder on Windows. Fix this and add a Windows specific
test case.
Task-number: QTBUG-26620
Change-Id: If58551ba01b56343ebf44512620207e49d83ba09
Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/folderlistmodel/qquickfolderlistmodel.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp index 409c2563f1..1cffa44c66 100644 --- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp @@ -83,6 +83,8 @@ public: void _q_directoryChanged(const QString &directory, const QList<FileProperty> &list); void _q_directoryUpdated(const QString &directory, const QList<FileProperty> &list, int fromIndex, int toIndex); void _q_sortFinished(const QList<FileProperty> &list); + + static QString resolvePath(const QUrl &path); }; @@ -195,6 +197,15 @@ void QQuickFolderListModelPrivate::_q_sortFinished(const QList<FileProperty> &li q->endInsertRows(); } +QString QQuickFolderListModelPrivate::resolvePath(const QUrl &path) +{ + QString localPath = QQmlFile::urlToLocalFileOrQrc(path); + QUrl localUrl = QUrl(localPath); + QString fullPath = localUrl.path(); + if (localUrl.scheme().length()) + fullPath = localUrl.scheme() + ":" + fullPath; + return QDir::cleanPath(fullPath); +} /*! \qmltype FolderListModel @@ -370,8 +381,7 @@ void QQuickFolderListModel::setFolder(const QUrl &folder) if (folder == d->currentDir) return; - QString localPath = QQmlFile::urlToLocalFileOrQrc(folder); - QString resolvedPath = QDir::cleanPath(QUrl(localPath).path()); + QString resolvedPath = QQuickFolderListModelPrivate::resolvePath(folder); beginResetModel(); @@ -413,8 +423,7 @@ void QQuickFolderListModel::setRootFolder(const QUrl &path) if (path.isEmpty()) return; - QString localPath = QQmlFile::urlToLocalFileOrQrc(path); - QString resolvedPath = QDir::cleanPath(QUrl(localPath).path()); + QString resolvedPath = QQuickFolderListModelPrivate::resolvePath(path); QFileInfo info(resolvedPath); if (!info.exists() || !info.isDir()) |