]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/folders/treeviewcontextmenu.cpp
Removed unused KGlobal includes and use KIO/Job instead of KIO/JobClasses
[dolphin.git] / src / panels / folders / treeviewcontextmenu.cpp
index 35e39c14a4ab50edb342369c3b96e8f1ec2c2da0..bbdf783cd1bc4c6a1597c8e1e084ffffaea90441 100644 (file)
 #include "treeviewcontextmenu.h"
 
 #include <KFileItem>
-#include <KIconLoader>
 #include <KIO/CopyJob>
 #include <KIO/DeleteJob>
 #include <KIO/JobUiDelegate>
-#include <KMenu>
+#include <QMenu>
 #include <QIcon>
 #include <KJobWidgets>
 #include <KSharedConfig>
 #include <KConfigGroup>
-#include <kurlmimedata.h>
+#include <KUrlMimeData>
 #include <KFileItemListProperties>
-#include <konq_operations.h>
-#include <KLocale>
+#include <KLocalizedString>
+#include <KIO/PasteJob>
 #include <KIO/Paste>
 #include <KIO/FileUndoManager>
 #include <KPropertiesDialog>
@@ -58,7 +57,7 @@ TreeViewContextMenu::~TreeViewContextMenu()
 
 void TreeViewContextMenu::open()
 {
-    KMenu* popup = new KMenu(m_parent);
+    QMenu* popup = new QMenu(m_parent);
 
     if (!m_fileItem.isNull()) {
         KFileItemListProperties capabilities(KFileItemList() << m_fileItem);
@@ -71,10 +70,12 @@ void TreeViewContextMenu::open()
         QAction* copyAction = new QAction(QIcon::fromTheme("edit-copy"), i18nc("@action:inmenu", "Copy"), this);
         connect(copyAction, &QAction::triggered, this, &TreeViewContextMenu::copy);
 
-        const QPair<bool, QString> pasteInfo = KonqOperations::pasteInfo(m_fileItem.url());
-        QAction* pasteAction = new QAction(QIcon::fromTheme("edit-paste"), pasteInfo.second, this);
+        const QMimeData *mimeData = QApplication::clipboard()->mimeData();
+        bool canPaste;
+        const QString text = KIO::pasteActionText(mimeData, &canPaste, m_fileItem);
+        QAction* pasteAction = new QAction(QIcon::fromTheme("edit-paste"), text, this);
         connect(pasteAction, &QAction::triggered, this, &TreeViewContextMenu::paste);
-        pasteAction->setEnabled(pasteInfo.first);
+        pasteAction->setEnabled(canPaste);
 
         popup->addAction(cutAction);
         popup->addAction(copyAction);
@@ -93,7 +94,7 @@ void TreeViewContextMenu::open()
         KConfigGroup configGroup(globalConfig, "KDE");
         bool showDeleteCommand = configGroup.readEntry("ShowDeleteCommand", false);
 
-        const KUrl url = m_fileItem.url();
+        const QUrl url = m_fileItem.url();
         if (url.isLocalFile()) {
             QAction* moveToTrashAction = new QAction(QIcon::fromTheme("user-trash"),
                                                     i18nc("@action:inmenu", "Move to Trash"), this);
@@ -147,7 +148,7 @@ void TreeViewContextMenu::open()
         }
     }
 
-    QWeakPointer<KMenu> popupPtr = popup;
+    QWeakPointer<QMenu> popupPtr = popup;
     popup->exec(QCursor::pos());
     if (popupPtr.data()) {
         popupPtr.data()->deleteLater();
@@ -156,9 +157,9 @@ void TreeViewContextMenu::open()
 
 void TreeViewContextMenu::populateMimeData(QMimeData* mimeData, bool cut)
 {
-    KUrl::List kdeUrls;
+    QList<QUrl> kdeUrls;
     kdeUrls.append(m_fileItem.url());
-    KUrl::List mostLocalUrls;
+    QList<QUrl> mostLocalUrls;
     bool dummy;
     mostLocalUrls.append(m_fileItem.mostLocalUrl(dummy));
     KIO::setClipboardDataCut(mimeData, cut);
@@ -181,7 +182,8 @@ void TreeViewContextMenu::copy()
 
 void TreeViewContextMenu::paste()
 {
-    KonqOperations::doPaste(m_parent, m_fileItem.url());
+    KIO::PasteJob *job = KIO::paste(QApplication::clipboard()->mimeData(), m_fileItem.url());
+    KJobWidgets::setWindow(job, m_parent);
 }
 
 void TreeViewContextMenu::rename()
@@ -191,12 +193,12 @@ void TreeViewContextMenu::rename()
 
 void TreeViewContextMenu::moveToTrash()
 {
-    KUrl::List list = KUrl::List() << m_fileItem.url();
+    const QList<QUrl> list{m_fileItem.url()};
     KIO::JobUiDelegate uiDelegate;
     uiDelegate.setWindow(m_parent);
     if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) {
         KIO::Job* job = KIO::trash(list);
-        KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, list, KUrl("trash:/"), job);
+        KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, list, QUrl("trash:/"), job);
         KJobWidgets::setWindow(job, m_parent);
         job->ui()->setAutoErrorHandlingEnabled(true);
     }
@@ -204,7 +206,7 @@ void TreeViewContextMenu::moveToTrash()
 
 void TreeViewContextMenu::deleteItem()
 {
-    KUrl::List list = KUrl::List() << m_fileItem.url();
+    const QList<QUrl> list{m_fileItem.url()};
     KIO::JobUiDelegate uiDelegate;
     uiDelegate.setWindow(m_parent);
     if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Delete, KIO::JobUiDelegate::DefaultConfirmation)) {