X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/848abc5922167a467bb73107ee6b72e9af3c8317..56888a56:/src/panels/folders/folderspanel.cpp diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index e455780e0..82b2e1b12 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -1,41 +1,29 @@ -/*************************************************************************** - * Copyright (C) 2006-2010 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ +/* + * SPDX-FileCopyrightText: 2006-2010 Peter Penz + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ #include "folderspanel.h" #include "dolphin_folderspanelsettings.h" #include "dolphin_generalsettings.h" -#include "treeviewcontextmenu.h" #include "foldersitemlistwidget.h" - -#include -#include -#include -#include -#include -#include +#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 #include #include #include #include +#include #include #include @@ -44,10 +32,6 @@ #include #include -#include - -#include "global.h" - FoldersPanel::FoldersPanel(QWidget* parent) : Panel(parent), m_updateCurrentItem(false), @@ -107,17 +91,14 @@ void FoldersPanel::rename(const KFileItem& item) const int index = m_model->index(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(); + KIO::RenameFileDialog* dialog = new KIO::RenameFileDialog(KFileItemList({item}), this); + 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; @@ -150,6 +131,7 @@ void FoldersPanel::showEvent(QShowEvent* event) // This assures that no performance and memory overhead is given when the folders panel is not // used at all and stays invisible. KFileItemListView* view = new KFileItemListView(); + view->setScanDirectories(false); view->setWidgetCreator(new KItemListWidgetCreator()); view->setSupportsItemExpanding(true); // Set the opacity to 0 initially. The opacity will be increased after the loading of the initial tree @@ -184,7 +166,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); } @@ -206,7 +188,7 @@ void FoldersPanel::slotItemActivated(int index) { const KFileItem item = m_model->fileItem(index); if (!item.isNull()) { - emit folderActivated(item.url()); + Q_EMIT folderActivated(item.url()); } } @@ -214,18 +196,16 @@ void FoldersPanel::slotItemMiddleClicked(int index) { const KFileItem item = m_model->fileItem(index); if (!item.isNull()) { - emit folderMiddleClicked(item.url()); + Q_EMIT folderMiddleClicked(item.url()); } } 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(); } @@ -233,10 +213,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(); } @@ -258,7 +236,7 @@ void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* eve KIO::DropJob *job = DragAndDropHelper::dropUrls(destItem.mostLocalUrl(), &dropEvent, this); if (job) { - connect(job, &KIO::DropJob::result, this, [this](KJob *job) { if (job->error()) emit errorMessage(job->errorString()); }); + connect(job, &KIO::DropJob::result, this, [this](KJob *job) { if (job->error()) Q_EMIT errorMessage(job->errorString()); }); } } } @@ -268,7 +246,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)); @@ -346,7 +324,7 @@ void FoldersPanel::loadTree(const QUrl& url, FoldersPanel::NavigationBehaviour n const int index = m_model->index(url); if (jumpHome) { - emit folderActivated(baseUrl); + Q_EMIT folderActivated(baseUrl); } else if (index >= 0) { updateCurrentItem(index); } else if (url == baseUrl) {