]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/folders/treeviewcontextmenu.cpp
GIT_SILENT made messages (after extraction)
[dolphin.git] / src / panels / folders / treeviewcontextmenu.cpp
index df9b9d62e5aba15270814b27907a83b1ce71dd4a..893a494fb817f7e6e07ceabac0ea58d233c4a977 100644 (file)
@@ -1,22 +1,9 @@
-/***************************************************************************
- *   Copyright (C) 2006-2010 by Peter Penz <peter.penz19@gmail.com>        *
- *   Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com>       *
- *                                                                         *
- *   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 <peter.penz19@gmail.com>
+ * SPDX-FileCopyrightText: 2006 Cvetoslav Ludmiloff <ludmiloff@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #include "treeviewcontextmenu.h"
 
@@ -27,8 +14,6 @@
 #include <KFileItemListProperties>
 #include <KIO/CopyJob>
 #include <KIO/DeleteJob>
-#include <KIO/FileUndoManager>
-#include <KIO/JobUiDelegate>
 #include <KIO/Paste>
 #include <KIO/PasteJob>
 #include <KJobWidgets>
 #include <KSharedConfig>
 #include <KUrlMimeData>
 
+#include <kio_version.h>
+#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0)
+#include <KIO/DeleteOrTrashJob>
+#else
+#include <KIO/FileUndoManager>
+#include <KIO/JobUiDelegate>
+#endif
+
 #include <QApplication>
 #include <QClipboard>
 #include <QMenu>
@@ -152,10 +145,10 @@ void TreeViewContextMenu::open(const QPoint& pos)
         popup->addAction(propertiesAction);
     }
 
-    QList<QAction*> customActions = m_parent->customContextMenuActions();
+    const QList<QAction*> customActions = m_parent->customContextMenuActions();
     if (!customActions.isEmpty()) {
         popup->addSeparator();
-        foreach (QAction* action, customActions) {
+        for (QAction* action : customActions) {
             popup->addAction(action);
         }
     }
@@ -173,8 +166,9 @@ void TreeViewContextMenu::populateMimeData(QMimeData* mimeData, bool cut)
     kdeUrls.append(m_fileItem.url());
     QList<QUrl> mostLocalUrls;
     bool dummy;
-    mostLocalUrls.append(m_fileItem.mostLocalUrl(dummy));
+    mostLocalUrls.append(m_fileItem.mostLocalUrl(&dummy));
     KIO::setClipboardDataCut(mimeData, cut);
+    KUrlMimeData::exportUrlsToPortal(mimeData);
     KUrlMimeData::setUrls(kdeUrls, mostLocalUrls, mimeData);
 }
 
@@ -205,6 +199,11 @@ void TreeViewContextMenu::rename()
 
 void TreeViewContextMenu::moveToTrash()
 {
+#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0)
+    using Iface = KIO::AskUserActionInterface;
+    auto *deleteJob = new KIO::DeleteOrTrashJob(QList{m_fileItem.url()}, Iface::Trash, Iface::DefaultConfirmation, m_parent);
+    deleteJob->start();
+#else
     const QList<QUrl> list{m_fileItem.url()};
     KIO::JobUiDelegate uiDelegate;
     uiDelegate.setWindow(m_parent);
@@ -214,10 +213,16 @@ void TreeViewContextMenu::moveToTrash()
         KJobWidgets::setWindow(job, m_parent);
         job->uiDelegate()->setAutoErrorHandlingEnabled(true);
     }
+#endif
 }
 
 void TreeViewContextMenu::deleteItem()
 {
+#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0)
+    using Iface = KIO::AskUserActionInterface;
+    auto *deleteJob = new KIO::DeleteOrTrashJob(QList{m_fileItem.url()}, Iface::Delete, Iface::DefaultConfirmation, m_parent);
+    deleteJob->start();
+#else
     const QList<QUrl> list{m_fileItem.url()};
     KIO::JobUiDelegate uiDelegate;
     uiDelegate.setWindow(m_parent);
@@ -226,6 +231,7 @@ void TreeViewContextMenu::deleteItem()
         KJobWidgets::setWindow(job, m_parent);
         job->uiDelegate()->setAutoErrorHandlingEnabled(true);
     }
+#endif
 }
 
 void TreeViewContextMenu::showProperties()