]> 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 e6cef5441383fd56eee8c54723e8ec207df66586..893a494fb817f7e6e07ceabac0ea58d233c4a977 100644 (file)
@@ -14,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>
@@ -139,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);
         }
     }
@@ -162,6 +168,7 @@ void TreeViewContextMenu::populateMimeData(QMimeData* mimeData, bool cut)
     bool dummy;
     mostLocalUrls.append(m_fileItem.mostLocalUrl(&dummy));
     KIO::setClipboardDataCut(mimeData, cut);
+    KUrlMimeData::exportUrlsToPortal(mimeData);
     KUrlMimeData::setUrls(kdeUrls, mostLocalUrls, mimeData);
 }
 
@@ -192,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);
@@ -201,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);
@@ -213,6 +231,7 @@ void TreeViewContextMenu::deleteItem()
         KJobWidgets::setWindow(job, m_parent);
         job->uiDelegate()->setAutoErrorHandlingEnabled(true);
     }
+#endif
 }
 
 void TreeViewContextMenu::showProperties()