#include "dolphin_folderspanelsettings.h"
#include "dolphin_generalsettings.h"
-#include "treeviewcontextmenu.h"
#include "foldersitemlistwidget.h"
+#include "global.h"
+#include "kitemviews/kfileitemlistview.h"
+#include "kitemviews/kfileitemmodel.h"
+#include "kitemviews/kitemlistcontainer.h"
+#include "kitemviews/kitemlistcontroller.h"
+#include "kitemviews/kitemlistselectionmanager.h"
+#include "treeviewcontextmenu.h"
+#include "views/draganddrophelper.h"
+#include "views/renamedialog.h"
-#include <views/renamedialog.h>
-#include <kitemviews/kitemlistselectionmanager.h>
-#include <kitemviews/kfileitemlistview.h>
-#include <kitemviews/kfileitemlistwidget.h>
-#include <kitemviews/kitemlistcontainer.h>
-#include <kitemviews/kitemlistcontroller.h>
-#include <kitemviews/kfileitemmodel.h>
-
-#include <KFileItem>
#include <KJobWidgets>
#include <KJobUiDelegate>
#include <KIO/CopyJob>
#include <QApplication>
#include <QBoxLayout>
-#include <QDropEvent>
#include <QGraphicsSceneDragDropEvent>
#include <QGraphicsView>
#include <QPropertyAnimation>
#include <QTimer>
-#include <views/draganddrophelper.h>
-
-#include "dolphindebug.h"
-#include "global.h"
-
FoldersPanel::FoldersPanel(QWidget* parent) :
Panel(parent),
m_updateCurrentItem(false),
m_controller->view()->editRole(index, "text");
} else {
RenameDialog* dialog = new RenameDialog(this, KFileItemList() << item);
- dialog->setAttribute(Qt::WA_DeleteOnClose);
- dialog->show();
- dialog->raise();
- dialog->activateWindow();
+ dialog->open();
}
}
void FoldersPanel::reloadTree()
{
if (m_controller) {
- loadTree(url());
+ loadTree(url(), AllowJumpHome);
}
}
anim->setDuration(200);
}
-void FoldersPanel::loadTree(const QUrl& url)
+void FoldersPanel::loadTree(const QUrl& url, FoldersPanel::NavigationBehaviour navigationBehaviour)
{
Q_ASSERT(m_controller);
m_updateCurrentItem = false;
+ bool jumpHome = false;
QUrl baseUrl;
- if (url.isLocalFile()) {
- const bool isInHomeFolder = Dolphin::homeUrl().isParentOf(url) || (Dolphin::homeUrl() == url);
- if (FoldersPanelSettings::limitFoldersPanelToHome() && isInHomeFolder) {
+ if (!url.isLocalFile()) {
+ // Clear the path for non-local URLs and use it as base
+ baseUrl = url;
+ baseUrl.setPath(QStringLiteral("/"));
+ } else if (Dolphin::homeUrl().isParentOf(url) || (Dolphin::homeUrl() == url)) {
+ if (FoldersPanelSettings::limitFoldersPanelToHome() ) {
baseUrl = Dolphin::homeUrl();
} else {
// Use the root directory as base for local URLs (#150941)
baseUrl = QUrl::fromLocalFile(QDir::rootPath());
}
+ } else if (FoldersPanelSettings::limitFoldersPanelToHome() && navigationBehaviour == AllowJumpHome) {
+ baseUrl = Dolphin::homeUrl();
+ jumpHome = true;
} else {
- // Clear the path for non-local URLs and use it as base
- baseUrl = url;
- baseUrl.setPath(QString('/'));
+ // Use the root directory as base for local URLs (#150941)
+ baseUrl = QUrl::fromLocalFile(QDir::rootPath());
}
- if (m_model->directory() != baseUrl) {
+ if (m_model->directory() != baseUrl && !jumpHome) {
m_updateCurrentItem = true;
m_model->refreshDirectory(baseUrl);
}
const int index = m_model->index(url);
- if (index >= 0) {
+ if (jumpHome) {
+ emit folderActivated(baseUrl);
+ } else if (index >= 0) {
updateCurrentItem(index);
} else if (url == baseUrl) {
// clear the selection when visiting the base url