From 7b595b3387cdb002c3e9a11e98a95d8801ca078d Mon Sep 17 00:00:00 2001 From: Michael Heidelbach Date: Wed, 3 Jan 2018 14:05:58 +0100 Subject: [PATCH] Revive folderpanel when outside $HOME Summary: Currently the folderpanel is inert when browsing outside of home because urls end up as 'file:////a/b/c' and since Qt 5.10 this is an invalid URL: http://code.qt.io/cgit/qt/qtbase.git/commit/?id=f62768d046528636789f901ac79e2cfa1843a7b7 Premptive bug fix. Test Plan: Open dolphin Leave home directory Reviewers: #dolphin, elvisangelaccio Subscribers: dfaure, elvisangelaccio, ngraham, anthonyfieroni Tags: #dolphin Differential Revision: https://phabricator.kde.org/D9610 --- src/kitemviews/kfileitemmodel.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 8f89b89df6..5919e64274 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -629,20 +629,24 @@ void KFileItemModel::restoreExpandedDirectories(const QSet &urls) void KFileItemModel::expandParentDirectories(const QUrl &url) { - const int pos = m_dirLister->url().path().length(); // Assure that each sub-path of the URL that should be // expanded is added to m_urlsToExpand. KDirLister // does not care whether the parent-URL has already been // expanded. QUrl urlToExpand = m_dirLister->url(); + const int pos = urlToExpand.path().length(); // first subdir can be empty, if m_dirLister->url().path() does not end with '/' // this happens if baseUrl is not root but a home directory, see FoldersPanel, // so using QString::SkipEmptyParts const QStringList subDirs = url.path().mid(pos).split(QDir::separator(), QString::SkipEmptyParts); for (int i = 0; i < subDirs.count() - 1; ++i) { - urlToExpand.setPath(urlToExpand.path() + '/' + subDirs.at(i)); + QString path = urlToExpand.path(); + if (!path.endsWith(QLatin1Char('/'))) { + path.append(QLatin1Char('/')); + } + urlToExpand.setPath(path + subDirs.at(i)); m_urlsToExpand.insert(urlToExpand); }