]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Port from KonqOperations::doPaste to new job KIO::paste
authorDavid Faure <faure@kde.org>
Sun, 2 Nov 2014 14:20:41 +0000 (15:20 +0100)
committerDavid Faure <faure@kde.org>
Sun, 2 Nov 2014 14:20:41 +0000 (15:20 +0100)
Remove KonqOperations::doPaste.

src/panels/folders/treeviewcontextmenu.cpp
src/views/dolphinview.cpp
src/views/dolphinview.h

index 85d1215c683108d443ccc42f0c42dce780b0667d..13a5c40f17a9a0cd29ada1c2ac20fdcbab26b681 100644 (file)
@@ -31,8 +31,8 @@
 #include <KConfigGroup>
 #include <kurlmimedata.h>
 #include <KFileItemListProperties>
-#include <konq_operations.h>
 #include <KLocalizedString>
+#include <KIO/PasteJob>
 #include <KIO/Paste>
 #include <KIO/FileUndoManager>
 #include <KPropertiesDialog>
@@ -182,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()
index b330e5f5c33643c20cd504ca947e25b63c5de1f0..7228b1131111123d476d3ca9ddb859f096b75e4d 100644 (file)
@@ -51,6 +51,7 @@
 #include <KIO/JobUiDelegate>
 #include <KIO/NetAccess>
 #include <KIO/PreviewJob>
+#include <KIO/PasteJob>
 #include <KIO/Paste>
 #include <KJob>
 #include <QMenu>
@@ -1040,16 +1041,19 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
                          event->modifiers());
 
     QString error;
-    KonqOperations* op = DragAndDropHelper::dropUrls(destItem, destUrl, &dropEvent, error);
+    KonqOperations* job = DragAndDropHelper::dropUrls(destItem, destUrl, &dropEvent, error);
     if (!error.isEmpty()) {
         emit infoMessage(error);
     }
 
-    if (op && destUrl == url()) {
+    if (job && destUrl == url()) {
         // Mark the dropped urls as selected.
         m_clearSelectionBeforeSelectingNewItems = true;
         m_markFirstNewlySelectedItemAsCurrent = true;
-        connect(op, static_cast<void(KonqOperations::*)(const QList<QUrl>&)>(&KonqOperations::aboutToCreate), this, &DolphinView::slotAboutToCreate);
+        connect(job, static_cast<void(KonqOperations::*)(const QList<QUrl>&)>(&KonqOperations::aboutToCreate), this, &DolphinView::slotAboutToCreate);
+        // TODO
+        //connect(job, &KIO::InteractiveDropJob::itemCreated, this, &DolphinView::slotItemCreated);
+        //connect(job, &KIO::InteractiveDropJob::result, this, &DolphinView::slotPasteJobResult);
     }
 
     setActive(true);
@@ -1096,6 +1100,22 @@ void DolphinView::slotAboutToCreate(const QList<QUrl>& urls)
     }
 }
 
+void DolphinView::slotItemCreated(const QUrl& url)
+{
+    if (m_markFirstNewlySelectedItemAsCurrent) {
+        markUrlAsCurrent(url);
+        m_markFirstNewlySelectedItemAsCurrent = false;
+    }
+    m_selectedUrls << url;
+}
+
+void DolphinView::slotPasteJobResult(KJob *)
+{
+    if (!m_selectedUrls.isEmpty()) {
+        m_selectedUrls << KDirModel::simplifiedUrlList(m_selectedUrls);
+    }
+}
+
 void DolphinView::slotSelectionChanged(const KItemSet& current, const KItemSet& previous)
 {
     const int currentCount = current.count();
@@ -1649,12 +1669,12 @@ void DolphinView::applyModeToView()
 
 void DolphinView::pasteToUrl(const QUrl& url)
 {
-    KonqOperations* op = KonqOperations::doPaste(this, url);
-    if (op) {
-        m_clearSelectionBeforeSelectingNewItems = true;
-        m_markFirstNewlySelectedItemAsCurrent = true;
-        connect(op, static_cast<void(KonqOperations::*)(const QList<QUrl>&)>(&KonqOperations::aboutToCreate), this, &DolphinView::slotAboutToCreate);
-    }
+    KIO::PasteJob *job = KIO::paste(QApplication::clipboard()->mimeData(), url);
+    KJobWidgets::setWindow(job, this);
+    m_clearSelectionBeforeSelectingNewItems = true;
+    m_markFirstNewlySelectedItemAsCurrent = true;
+    connect(job, &KIO::PasteJob::itemCreated, this, &DolphinView::slotItemCreated);
+    connect(job, &KIO::PasteJob::result, this, &DolphinView::slotPasteJobResult);
 }
 
 QList<QUrl> DolphinView::simplifiedSelectedUrls() const
index 17add7420d19def934db895f61f054cf0af7bd44..2f7b63dd5572872301657e32c06ec36d0e5579d4 100644 (file)
@@ -572,6 +572,11 @@ private slots:
     /*
      * Is called when new items get pasted or dropped.
      */
+    void slotItemCreated(const QUrl &url);
+    /*
+     * Is called after all pasted or dropped items have been copied to destination.
+     */
+    void slotPasteJobResult(KJob *job);
     void slotAboutToCreate(const QList<QUrl> &urls);
 
     /**