┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/views')
-rw-r--r--src/views/dolphinview.cpp11
-rw-r--r--src/views/draganddrophelper.cpp18
-rw-r--r--src/views/draganddrophelper.h7
3 files changed, 19 insertions, 17 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 0edcb2894..f17749b83 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -815,7 +815,14 @@ void DolphinView::slotItemUnhovered(int index)
void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
{
- const KFileItem destItem = fileItemModel()->fileItem(index);
+ KFileItem destItem = fileItemModel()->fileItem(index);
+ if (destItem.isNull()) {
+ destItem = fileItemModel()->rootItem();
+ if (destItem.isNull()) {
+ kWarning() << "No destination item available for drop operation.";
+ return;
+ }
+ }
QDropEvent dropEvent(event->pos().toPoint(),
event->possibleActions(),
@@ -823,7 +830,7 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
event->buttons(),
event->modifiers());
- const QString error = DragAndDropHelper::dropUrls(destItem, url(), &dropEvent);
+ const QString error = DragAndDropHelper::dropUrls(destItem, &dropEvent);
if (!error.isEmpty()) {
emit errorMessage(error);
}
diff --git a/src/views/draganddrophelper.cpp b/src/views/draganddrophelper.cpp
index ea92787ab..91eb4267d 100644
--- a/src/views/draganddrophelper.cpp
+++ b/src/views/draganddrophelper.cpp
@@ -28,12 +28,14 @@
#include <QtDBus>
#include <QDropEvent>
-QString DragAndDropHelper::dropUrls(const KFileItem& destItem,
- const KUrl& destPath,
- QDropEvent* event)
+QString DragAndDropHelper::dropUrls(const KFileItem& destItem, QDropEvent* event)
{
- const bool dropToItem = !destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile());
- const KUrl destination = dropToItem ? destItem.url() : destPath;
+ 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());
+ }
const QMimeData* mimeData = event->mimeData();
if (mimeData->hasFormat("application/x-kde-dndextract")) {
@@ -50,11 +52,7 @@ QString DragAndDropHelper::dropUrls(const KFileItem& destItem,
}
}
- if (dropToItem) {
- KonqOperations::doDrop(destItem, destination, event, QApplication::activeWindow());
- } else {
- KonqOperations::doDrop(KFileItem(), destination, event, QApplication::activeWindow());
- }
+ KonqOperations::doDrop(destItem, destination, event, QApplication::activeWindow());
}
return QString();
diff --git a/src/views/draganddrophelper.h b/src/views/draganddrophelper.h
index d00e11157..1998a85a0 100644
--- a/src/views/draganddrophelper.h
+++ b/src/views/draganddrophelper.h
@@ -38,15 +38,12 @@ 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 (can be null, see KFileItem::isNull()).
- * @param destPath Path of the destination.
+ * @param destItem Item of the destination.
* @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,
- const KUrl& destPath,
- QDropEvent* event);
+ static QString dropUrls(const KFileItem& destItem, QDropEvent* event);
};
#endif