┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-01-30 12:07:08 +0100
committerPeter Penz <[email protected]>2012-01-30 12:09:36 +0100
commit1d7088b1ada3de716ff591c22d400198450208d4 (patch)
tree98dcb98cb56b1d09f2447acf2b7237eb02c8173e /src/views
parent0a33aad3d28048720247faa3acdb4d32849e25b5 (diff)
Fix drag & drop issues with non-local URLs
BUG: 292821 BUG: 292355 FIXED-IN: 4.8.1
Diffstat (limited to 'src/views')
-rw-r--r--src/views/dolphinview.cpp17
-rw-r--r--src/views/draganddrophelper.cpp15
-rw-r--r--src/views/draganddrophelper.h11
3 files changed, 21 insertions, 22 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 539fcaacc..1e300c5cf 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -809,13 +809,13 @@ void DolphinView::slotItemUnhovered(int index)
void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
{
+ KUrl destUrl;
KFileItem destItem = fileItemModel()->fileItem(index);
if (destItem.isNull()) {
destItem = fileItemModel()->rootItem();
- if (destItem.isNull()) {
- kWarning() << "No destination item available for drop operation.";
- return;
- }
+ destUrl = url();
+ } else {
+ destUrl = destItem.url();
}
QDropEvent dropEvent(event->pos().toPoint(),
@@ -824,7 +824,7 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
event->buttons(),
event->modifiers());
- const QString error = DragAndDropHelper::dropUrls(destItem, &dropEvent);
+ const QString error = DragAndDropHelper::dropUrls(destItem, destUrl, &dropEvent);
if (!error.isEmpty()) {
emit errorMessage(error);
}
@@ -959,12 +959,7 @@ bool DolphinView::hasSelection() const
KFileItem DolphinView::rootItem() const
{
- KFileItem item = m_dirLister->rootItem();
- if (item.isNull()) {
- // The directory has not been loaded yet
- item = KFileItem(KFileItem::Unknown, KFileItem::Unknown, url());
- }
- return item;
+ return m_dirLister->rootItem();
}
void DolphinView::observeCreatedItem(const KUrl& url)
diff --git a/src/views/draganddrophelper.cpp b/src/views/draganddrophelper.cpp
index 91eb4267d..83673ad72 100644
--- a/src/views/draganddrophelper.cpp
+++ b/src/views/draganddrophelper.cpp
@@ -28,13 +28,10 @@
#include <QtDBus>
#include <QDropEvent>
-QString DragAndDropHelper::dropUrls(const KFileItem& destItem, QDropEvent* event)
+QString DragAndDropHelper::dropUrls(const KFileItem& destItem, const KUrl& destUrl, QDropEvent* event)
{
- Q_ASSERT(!destItem.isNull());
-
- const KUrl destination = destItem.url();
- if (!destItem.isWritable()) {
- return i18nc("@info:status", "Access denied. Could not write to <filename>%1</filename>", destination.pathOrUrl());
+ if (!destItem.isNull() && !destItem.isWritable()) {
+ return i18nc("@info:status", "Access denied. Could not write to <filename>%1</filename>", destUrl.pathOrUrl());
}
const QMimeData* mimeData = event->mimeData();
@@ -42,17 +39,17 @@ QString DragAndDropHelper::dropUrls(const KFileItem& destItem, QDropEvent* event
const QString remoteDBusClient = mimeData->data("application/x-kde-dndextract");
QDBusMessage message = QDBusMessage::createMethodCall(remoteDBusClient, "/DndExtract",
"org.kde.DndExtract", "extractSelectedFilesTo");
- message.setArguments(QVariantList() << destination.pathOrUrl());
+ message.setArguments(QVariantList() << destUrl.pathOrUrl());
QDBusConnection::sessionBus().call(message);
} else {
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
foreach (const KUrl& url, urls) {
- if (url == destination) {
+ if (url == destUrl) {
return i18nc("@info:status", "A folder cannot be dropped into itself");
}
}
- KonqOperations::doDrop(destItem, destination, event, QApplication::activeWindow());
+ KonqOperations::doDrop(destItem, destUrl, event, QApplication::activeWindow());
}
return QString();
diff --git a/src/views/draganddrophelper.h b/src/views/draganddrophelper.h
index 1998a85a0..8838648a0 100644
--- a/src/views/draganddrophelper.h
+++ b/src/views/draganddrophelper.h
@@ -38,12 +38,19 @@ public:
* destination. A context menu with the options
* 'Move Here', 'Copy Here', 'Link Here' and
* 'Cancel' is offered to the user.
- * @param destItem Item of the destination.
+ * @param destItem Item of the destination. Can be 0 (KFileItem::isNull()) if
+ * no file-item is available for the destination. In this case
+ * destUrl is used as fallback. For performance reasons it is
+ * recommended to pass a file-item if available.
+ * @param destUrl URL of the item destination. Is used only if destItem::isNull()
+ * is true.
* @param event Drop event.
* @return Error message if dropping is not possible. If an empty string
* is returned, the dropping has been successful.
*/
- static QString dropUrls(const KFileItem& destItem, QDropEvent* event);
+ static QString dropUrls(const KFileItem& destItem,
+ const KUrl& destUrl,
+ QDropEvent* event);
};
#endif