diff options
| author | David Faure <[email protected]> | 2014-12-26 08:57:42 +0100 |
|---|---|---|
| committer | David Faure <[email protected]> | 2015-01-05 09:07:10 +0100 |
| commit | 7bd5bec21977c733dd3e1fc70f5afd66dda3ab97 (patch) | |
| tree | c05c3ecc54e25320dbd609ae65b6afdc23d07c0d /src/views/draganddrophelper.cpp | |
| parent | 119f7a3fce241efddc7e7f9eef8e729cf9ad35c2 (diff) | |
Dolphin: port from KonqOperations::doDrop to the new KIO::DropJob
REVIEW: 121678
Diffstat (limited to 'src/views/draganddrophelper.cpp')
| -rw-r--r-- | src/views/draganddrophelper.cpp | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/src/views/draganddrophelper.cpp b/src/views/draganddrophelper.cpp index a09faa345..f740fd520 100644 --- a/src/views/draganddrophelper.cpp +++ b/src/views/draganddrophelper.cpp @@ -20,25 +20,20 @@ #include "draganddrophelper.h" -#include <KFileItem> -#include <KLocalizedString> -#include <konq_operations.h> #include <QUrl> -#include <QApplication> -#include <QtDBus> +#include <QDBusMessage> +#include <QDBusConnection> #include <QDropEvent> +#include <QMimeData> + +#include <KFileItem> +#include <KLocalizedString> #include <KUrlMimeData> +#include <KIO/DropJob> +#include <KJobWidgets> -KonqOperations* DragAndDropHelper::dropUrls(const KFileItem& destItem, const QUrl& destUrl, QDropEvent* event, QString& error) +KIO::DropJob* DragAndDropHelper::dropUrls(const QUrl& destUrl, QDropEvent* event, QWidget* window) { - error.clear(); - - if (!destItem.isNull() && !destItem.isWritable()) { - error = xi18nc("@info:status", "Access denied. Could not write to <filename>%1</filename>", - destUrl.toDisplayString(QUrl::PreferLocalFile)); - return 0; - } - const QMimeData* mimeData = event->mimeData(); if (mimeData->hasFormat("application/x-kde-ark-dndextract-service") && mimeData->hasFormat("application/x-kde-ark-dndextract-path")) { @@ -49,19 +44,11 @@ KonqOperations* DragAndDropHelper::dropUrls(const KFileItem& destItem, const QUr "org.kde.ark.DndExtract", "extractSelectedFilesTo"); message.setArguments({destUrl.toDisplayString(QUrl::PreferLocalFile)}); QDBusConnection::sessionBus().call(message); - } else if (!destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile())) { - // Drop into a directory or a desktop-file - const QList<QUrl> urls = KUrlMimeData::urlsFromMimeData(mimeData); - foreach (const QUrl& url, urls) { - if (url == destUrl) { - error = i18nc("@info:status", "A folder cannot be dropped into itself"); - return 0; - } - } - - return KonqOperations::doDrop(destItem, destUrl, event, QApplication::activeWindow(), QList<QAction*>()); } else { - return KonqOperations::doDrop(KFileItem(), destUrl, event, QApplication::activeWindow(), QList<QAction*>()); + // Drop into a directory or a desktop-file + KIO::DropJob *job = KIO::drop(event, destUrl); + KJobWidgets::setWindow(job, window); + return job; } return 0; |
