X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/3cb3d58fbf0a5d3736579ad7a52a2a46ab9c1d29..681d8bb6c:/src/panels/folders/folderspanel.cpp diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index add7f692b..01f338461 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -21,18 +21,17 @@ #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 -#include -#include -#include -#include -#include -#include - -#include #include #include #include @@ -41,17 +40,11 @@ #include #include -#include #include #include #include #include -#include - -#include "dolphindebug.h" -#include "global.h" - FoldersPanel::FoldersPanel(QWidget* parent) : Panel(parent), m_updateCurrentItem(false), @@ -112,16 +105,13 @@ void FoldersPanel::rename(const KFileItem& item) 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(); } } bool FoldersPanel::urlChanged() { - if (!url().isValid() || url().scheme().contains(QStringLiteral("search"))) { + if (!url().isValid() || url().scheme().contains(QLatin1String("search"))) { // Skip results shown by a search, as possible identical // directory names are useless without parent-path information. return false; @@ -137,7 +127,7 @@ bool FoldersPanel::urlChanged() void FoldersPanel::reloadTree() { if (m_controller) { - loadTree(url(), true); + loadTree(url(), AllowJumpHome); } } @@ -188,7 +178,7 @@ void FoldersPanel::showEvent(QShowEvent* event) container->setEnabledFrame(false); QVBoxLayout* layout = new QVBoxLayout(this); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(container); } @@ -224,12 +214,10 @@ void FoldersPanel::slotItemMiddleClicked(int index) void FoldersPanel::slotItemContextMenuRequested(int index, const QPointF& pos) { - Q_UNUSED(pos); - const KFileItem fileItem = m_model->fileItem(index); QPointer contextMenu = new TreeViewContextMenu(this, fileItem); - contextMenu.data()->open(); + contextMenu.data()->open(pos.toPoint()); if (contextMenu.data()) { delete contextMenu.data(); } @@ -237,10 +225,8 @@ void FoldersPanel::slotItemContextMenuRequested(int index, const QPointF& pos) void FoldersPanel::slotViewContextMenuRequested(const QPointF& pos) { - Q_UNUSED(pos); - QPointer contextMenu = new TreeViewContextMenu(this, KFileItem()); - contextMenu.data()->open(); + contextMenu.data()->open(pos.toPoint()); if (contextMenu.data()) { delete contextMenu.data(); } @@ -272,7 +258,7 @@ void FoldersPanel::slotRoleEditingFinished(int index, const QByteArray& role, co if (role == "text") { const KFileItem item = m_model->fileItem(index); const QString newName = value.toString(); - if (!newName.isEmpty() && newName != item.text() && newName != QLatin1String(".") && newName != QLatin1String("..")) { + if (!newName.isEmpty() && newName != item.text() && newName != QLatin1Char('.') && newName != QLatin1String("..")) { const QUrl oldUrl = item.url(); QUrl newUrl = oldUrl.adjusted(QUrl::RemoveFilename); newUrl.setPath(newUrl.path() + KIO::encodeFileName(newName)); @@ -316,7 +302,7 @@ void FoldersPanel::startFadeInAnimation() anim->setDuration(200); } -void FoldersPanel::loadTree(const QUrl& url, bool allowJumpHome) +void FoldersPanel::loadTree(const QUrl& url, FoldersPanel::NavigationBehaviour navigationBehaviour) { Q_ASSERT(m_controller); @@ -327,7 +313,7 @@ void FoldersPanel::loadTree(const QUrl& url, bool allowJumpHome) if (!url.isLocalFile()) { // Clear the path for non-local URLs and use it as base baseUrl = url; - baseUrl.setPath(QString('/')); + baseUrl.setPath(QStringLiteral("/")); } else if (Dolphin::homeUrl().isParentOf(url) || (Dolphin::homeUrl() == url)) { if (FoldersPanelSettings::limitFoldersPanelToHome() ) { baseUrl = Dolphin::homeUrl(); @@ -335,7 +321,7 @@ void FoldersPanel::loadTree(const QUrl& url, bool allowJumpHome) // Use the root directory as base for local URLs (#150941) baseUrl = QUrl::fromLocalFile(QDir::rootPath()); } - } else if (FoldersPanelSettings::limitFoldersPanelToHome() && allowJumpHome) { + } else if (FoldersPanelSettings::limitFoldersPanelToHome() && navigationBehaviour == AllowJumpHome) { baseUrl = Dolphin::homeUrl(); jumpHome = true; } else { @@ -349,7 +335,7 @@ void FoldersPanel::loadTree(const QUrl& url, bool allowJumpHome) } const int index = m_model->index(url); - if (jumpHome == true) { + if (jumpHome) { emit folderActivated(baseUrl); } else if (index >= 0) { updateCurrentItem(index);