diff options
Diffstat (limited to 'src/views')
| -rw-r--r-- | src/views/dolphinview.cpp | 5 | ||||
| -rw-r--r-- | src/views/draganddrophelper.cpp | 7 | ||||
| -rw-r--r-- | src/views/draganddrophelper.h | 14 |
3 files changed, 17 insertions, 9 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 16163c8e9..80be1e592 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -830,10 +830,13 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even { KUrl destUrl; KFileItem destItem = fileItemModel()->fileItem(index); - if (destItem.isNull()) { + if (destItem.isNull() || (!destItem.isDir() && !destItem.isDesktopFile())) { + // Use the URL of the view as drop target if the item is no directory + // or desktop-file destItem = fileItemModel()->rootItem(); destUrl = url(); } else { + // The item represents a directory or desktop-file destUrl = destItem.url(); } diff --git a/src/views/draganddrophelper.cpp b/src/views/draganddrophelper.cpp index 83673ad72..2cd1e86e0 100644 --- a/src/views/draganddrophelper.cpp +++ b/src/views/draganddrophelper.cpp @@ -41,15 +41,18 @@ QString DragAndDropHelper::dropUrls(const KFileItem& destItem, const KUrl& destU "org.kde.DndExtract", "extractSelectedFilesTo"); message.setArguments(QVariantList() << destUrl.pathOrUrl()); QDBusConnection::sessionBus().call(message); - } else { + } else if (!destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile())) { + // Drop into a directory or a desktop-file const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); foreach (const KUrl& url, urls) { if (url == destUrl) { return i18nc("@info:status", "A folder cannot be dropped into itself"); } } - + KonqOperations::doDrop(destItem, destUrl, event, QApplication::activeWindow()); + } else { + KonqOperations::doDrop(KFileItem(), destUrl, event, QApplication::activeWindow()); } return QString(); diff --git a/src/views/draganddrophelper.h b/src/views/draganddrophelper.h index 8838648a0..ac16f7cf2 100644 --- a/src/views/draganddrophelper.h +++ b/src/views/draganddrophelper.h @@ -34,10 +34,11 @@ class LIBDOLPHINPRIVATE_EXPORT DragAndDropHelper { public: /** - * Handles the dropping of URLs to the given - * destination. A context menu with the options - * 'Move Here', 'Copy Here', 'Link Here' and - * 'Cancel' is offered to the user. + * Handles the dropping of URLs to the given destination. A context menu + * with the options 'Move Here', 'Copy Here', 'Link Here' and 'Cancel' is + * offered to the user. The drag destination must represent a directory or + * a desktop-file, otherwise the dropping gets ignored. + * * @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 @@ -45,8 +46,9 @@ public: * @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. + * @return Error message intended to be shown for users if dropping is not + * possible. If an empty string is returned, the dropping has been + * successful. */ static QString dropUrls(const KFileItem& destItem, const KUrl& destUrl, |
