summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphael Kubo da Costa <kubito@gmail.com>2011-05-02 02:35:01 (GMT)
committerRaphael Kubo da Costa <kubito@gmail.com>2011-05-02 02:35:01 (GMT)
commitd37a244a3c6dd80f2f4403d6aaabc63b3700e3ca (patch)
treed68b10078b6f76a3b9c650b6924e4d5f8cc045fd
parentdfd50bf581118304678dbf9abfe84ac92e1e4051 (diff)
Make folderview understand application/x-kde-dndextract.
The code was copied almost as-is from Dolphin's implementation. It should now be possible to drag and drop files from any archive opened in Ark to folderview. It previously worked with some archive types due to a weird code path in Ark which should not exist. PS: Fredrik, I ended up using pathOrUrl() because I can't pass KUrl via DBus. Reviewed-by: Fredrik Höglund CCMAIL: fredrik@kde.org CCBUG: 189322
-rw-r--r--plasma/applets/folderview/iconview.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/plasma/applets/folderview/iconview.cpp b/plasma/applets/folderview/iconview.cpp
index 937e6b2..206aff7 100644
--- a/plasma/applets/folderview/iconview.cpp
+++ b/plasma/applets/folderview/iconview.cpp
@@ -2027,7 +2027,8 @@ void IconView::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
void IconView::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
- bool accepted = KUrl::List::canDecode(event->mimeData());
+ const bool accepted = KUrl::List::canDecode(event->mimeData()) ||
+ event->mimeData()->hasFormat(QLatin1String("application/x-kde-dndextract"));
event->setAccepted(accepted);
m_hoverDrag = accepted;
}
@@ -2193,11 +2194,26 @@ void IconView::dropEvent(QGraphicsSceneDragDropEvent *event)
}
if (!item.isNull()) {
- QDropEvent ev(event->screenPos(), event->possibleActions(), event->mimeData(),
+ const QMimeData *mimeData = event->mimeData();
+
+ QDropEvent ev(event->screenPos(), event->possibleActions(), mimeData,
event->buttons(), event->modifiers());
ev.setDropAction(event->dropAction());
//kDebug() << "dropping to" << m_url << "with" << view() << event->modifiers();
+ if (mimeData->hasFormat(QLatin1String("application/x-kde-dndextract"))) {
+ const QString remoteDBusClient = mimeData->data(QLatin1String("application/x-kde-dndextract"));
+
+ QDBusMessage message =
+ QDBusMessage::createMethodCall(remoteDBusClient, QLatin1String("/DndExtract"),
+ QLatin1String("org.kde.DndExtract"),
+ QLatin1String("extractSelectedFilesTo"));
+ message.setArguments(QVariantList() << m_dirModel->dirLister()->url().pathOrUrl());
+
+ QDBusConnection::sessionBus().call(message);
+ return;
+ }
+
// If we're dropping on the view itself
QList<QAction *> userActions;
if (!m_hoveredIndex.isValid()) {