]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.cpp
Dolphin: port from KonqOperations::doDrop to the new KIO::DropJob
[dolphin.git] / src / views / dolphinview.cpp
index 00281af73dba7668cf041f8171ee727744e3be5e..32e182ce7c15bf1518b7e928cfff99188e7605af 100644 (file)
 #include <KIO/JobUiDelegate>
 #include <KIO/NetAccess>
 #include <KIO/PreviewJob>
+#include <KIO/DropJob>
 #include <KIO/PasteJob>
 #include <KIO/Paste>
 #include <KJob>
 #include <QMenu>
 #include <KMessageBox>
 #include <KJobWidgets>
-#include <konq_operations.h>
 #include <QUrl>
 
 #include "dolphinnewfilemenuobserver.h"
@@ -1039,22 +1039,22 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
                          event->mimeData(),
                          event->buttons(),
                          event->modifiers());
+    dropUrls(destUrl, &dropEvent);
 
-    QString error;
-    KonqOperations* job = DragAndDropHelper::dropUrls(destItem, destUrl, &dropEvent, error);
-    if (!error.isEmpty()) {
-        emit infoMessage(error);
-    }
+    setActive(true);
+}
+
+void DolphinView::dropUrls(const QUrl &destUrl, QDropEvent *dropEvent)
+{
+    KIO::DropJob* job = DragAndDropHelper::dropUrls(destUrl, dropEvent, this);
 
     if (job && destUrl == url()) {
         // Mark the dropped urls as selected.
         m_clearSelectionBeforeSelectingNewItems = true;
         m_markFirstNewlySelectedItemAsCurrent = true;
-        connect(job, &KonqOperations::itemCreated, this, &DolphinView::slotItemCreated);
-        //connect(job, &KIO::InteractiveDropJob::result, this, &DolphinView::slotPasteJobResult);
+        connect(job, &KIO::DropJob::itemCreated, this, &DolphinView::slotItemCreated);
+        connect(job, &KIO::DropJob::result, this, &DolphinView::slotPasteJobResult);
     }
-
-    setActive(true);
 }
 
 void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous)
@@ -1096,8 +1096,11 @@ void DolphinView::slotItemCreated(const QUrl& url)
     m_selectedUrls << url;
 }
 
-void DolphinView::slotPasteJobResult(KJob *)
+void DolphinView::slotPasteJobResult(KJob *job)
 {
+    if (job->error()) {
+        emit errorMessage(job->errorString());
+    }
     if (!m_selectedUrls.isEmpty()) {
         m_selectedUrls << KDirModel::simplifiedUrlList(m_selectedUrls);
     }
@@ -1698,7 +1701,8 @@ void DolphinView::updateWritableState()
     if (item.isNull()) {
         // Try to find out if the URL is writable even if the "root item" is
         // null, see https://bugs.kde.org/show_bug.cgi?id=330001
-        item = KFileItem(KFileItem::Unknown, KFileItem::Unknown, url(), true);
+        item = KFileItem(url());
+        item.setDelayedMimeTypes(true);
     }
 
     KFileItemListProperties capabilities(KFileItemList() << item);