┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/panels/folders/folderspanel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/panels/folders/folderspanel.cpp')
-rw-r--r--src/panels/folders/folderspanel.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp
index 8b759d813..cb35fd218 100644
--- a/src/panels/folders/folderspanel.cpp
+++ b/src/panels/folders/folderspanel.cpp
@@ -50,6 +50,7 @@
#include <views/draganddrophelper.h>
#include "dolphindebug.h"
+#include "global.h"
FoldersPanel::FoldersPanel(QWidget* parent) :
Panel(parent),
@@ -82,6 +83,17 @@ bool FoldersPanel::showHiddenFiles() const
return FoldersPanelSettings::hiddenFilesShown();
}
+void FoldersPanel::setLimitFoldersPanelToHome(bool enable)
+{
+ FoldersPanelSettings::setLimitFoldersPanelToHome(enable);
+ reloadTree();
+}
+
+bool FoldersPanel::limitFoldersPanelToHome() const
+{
+ return FoldersPanelSettings::limitFoldersPanelToHome();
+}
+
void FoldersPanel::setAutoScrolling(bool enable)
{
// TODO: Not supported yet in Dolphin 2.0
@@ -122,6 +134,14 @@ bool FoldersPanel::urlChanged()
return true;
}
+void FoldersPanel::reloadTree()
+{
+ if (m_controller) {
+ loadTree(url());
+ }
+}
+
+
void FoldersPanel::showEvent(QShowEvent* event)
{
if (event->spontaneous()) {
@@ -304,8 +324,13 @@ void FoldersPanel::loadTree(const QUrl& url)
QUrl baseUrl;
if (url.isLocalFile()) {
- // Use the root directory as base for local URLs (#150941)
- baseUrl = QUrl::fromLocalFile(QDir::rootPath());
+ const bool isInHomeFolder = Dolphin::homeUrl().isParentOf(url) || (Dolphin::homeUrl() == url);
+ if (FoldersPanelSettings::limitFoldersPanelToHome() && isInHomeFolder) {
+ baseUrl = Dolphin::homeUrl();
+ } else {
+ // Use the root directory as base for local URLs (#150941)
+ baseUrl = QUrl::fromLocalFile(QDir::rootPath());
+ }
} else {
// Clear the path for non-local URLs and use it as base
baseUrl = url;
@@ -320,9 +345,13 @@ void FoldersPanel::loadTree(const QUrl& url)
const int index = m_model->index(url);
if (index >= 0) {
updateCurrentItem(index);
+ } else if (url == baseUrl) {
+ // clear the selection when visiting the base url
+ updateCurrentItem(-1);
} else {
m_updateCurrentItem = true;
m_model->expandParentDirectories(url);
+
// slotLoadingCompleted() will be invoked after the model has
// expanded the url
}