From 94fab8c80ed60958043d13145aaf4c54412e052f Mon Sep 17 00:00:00 2001 From: Robert Hoffmann Date: Fri, 1 Sep 2017 10:15:03 +0200 Subject: Limit folder panel to home directory if inside home Summary: Added the option to limit the displayed folders in the folder panel (F7) to the tree below the user's home directory if the current URL is inside the home directory. This can be configured in the preferences General/Behaviour tab by checking the corresponding check box. Reviewers: #dolphin, elvisangelaccio, emmanuelp Reviewed By: #dolphin, elvisangelaccio, emmanuelp Subscribers: emmanuelp, elvisangelaccio, #konqueror, #dolphin Differential Revision: https://phabricator.kde.org/D7477 --- src/kitemviews/kfileitemmodel.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/kitemviews/kfileitemmodel.cpp') diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index f2f44eab4..6ca9fce6c 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -636,7 +636,11 @@ void KFileItemModel::expandParentDirectories(const QUrl &url) // does not care whether the parent-URL has already been // expanded. QUrl urlToExpand = m_dirLister->url(); - const QStringList subDirs = url.path().mid(pos).split(QDir::separator()); + + // 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)); m_urlsToExpand.insert(urlToExpand); -- cgit v1.3