C++ (Qt) //prepare the dbus-based drag/drop mimedata QMimeData *data = new QMimeData(); data->setData("application/x-kde-dndextract", QDBusConnection::sessionBus().baseService().toUtf8() );
if (!noFallback) kiolist.populateMimeData(data); return data;
C++ (Qt)void DragAndDropHelper::dropUrls(const KFileItem& destItem, const KUrl& destPath, QDropEvent* event, QWidget* widget){ const bool dropToItem = !destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile()); const KUrl destination = dropToItem ? destItem.url() : destPath; const QMimeData* mimeData = event->mimeData(); if (mimeData->hasFormat("application/x-kde-dndextract")) { QString remoteDBusClient = mimeData->data("application/x-kde-dndextract"); QDBusMessage message = QDBusMessage::createMethodCall(remoteDBusClient, "/DndExtract", "org.kde.DndExtract", "extractSelectedFilesTo"); message.setArguments(QVariantList() << destination.path()); QDBusConnection::sessionBus().call(message); } else { const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); const int urlsCount = urls.count(); if (urlsCount == 0) { // TODO: handle dropping of other data } else if ((urlsCount == 1) && (urls.first() == destination)) { emit errorMessage(i18nc("@info:status", "A folder cannot be dropped into itself")); } else if (dropToItem) { KonqOperations::doDrop(destItem, destination, event, widget); } else { KonqOperations::doDrop(KFileItem(), destination, event, widget); } }}