summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <peter.penz19@gmail.com>2012-02-08 14:16:35 (GMT)
committerPeter Penz <peter.penz19@gmail.com>2012-02-08 16:47:14 (GMT)
commit13d975a6d7ea6552202a13d0d324754a4247d730 (patch)
tree79f902bff0d7569e9d84d8d7bb0e15883531e6d8
parent74e44ad91b33268ef014cad32548d76517d848b1 (diff)
Drag and drop: Adjust destination if the item is no directory or desktop-file
The URL of the view should be used as destination target if a dropping is not done above a directory or desktop-file. BUG: 293511 FIXED-IN: 4.8.1
-rw-r--r--dolphin/src/kitemviews/kfileitemmodel.cpp2
-rw-r--r--dolphin/src/panels/folders/folderspanel.cpp3
-rw-r--r--dolphin/src/views/dolphinview.cpp5
-rw-r--r--dolphin/src/views/draganddrophelper.cpp7
-rw-r--r--dolphin/src/views/draganddrophelper.h14
5 files changed, 19 insertions, 12 deletions
diff --git a/dolphin/src/kitemviews/kfileitemmodel.cpp b/dolphin/src/kitemviews/kfileitemmodel.cpp
index 6cb7577..e0ae033 100644
--- a/dolphin/src/kitemviews/kfileitemmodel.cpp
+++ b/dolphin/src/kitemviews/kfileitemmodel.cpp
@@ -257,7 +257,7 @@ int KFileItemModel::indexForKeyboardSearch(const QString& text, int startFromInd
bool KFileItemModel::supportsDropping(int index) const
{
const KFileItem item = fileItem(index);
- return item.isNull() ? false : item.isDir();
+ return item.isNull() ? false : item.isDir() || item.isDesktopFile();
}
QString KFileItemModel::roleDescription(const QByteArray& role) const
diff --git a/dolphin/src/panels/folders/folderspanel.cpp b/dolphin/src/panels/folders/folderspanel.cpp
index 3b24f58..1a5e9c6 100644
--- a/dolphin/src/panels/folders/folderspanel.cpp
+++ b/dolphin/src/panels/folders/folderspanel.cpp
@@ -255,8 +255,7 @@ void FoldersPanel::slotViewContextMenuRequested(const QPointF& pos)
void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
{
if (index >= 0) {
- KFileItemModel* model = fileItemModel();
- KFileItem destItem = model->fileItem(index);
+ KFileItem destItem = fileItemModel()->fileItem(index);
if (destItem.isNull()) {
return;
}
diff --git a/dolphin/src/views/dolphinview.cpp b/dolphin/src/views/dolphinview.cpp
index 16163c8..80be1e5 100644
--- a/dolphin/src/views/dolphinview.cpp
+++ b/dolphin/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/dolphin/src/views/draganddrophelper.cpp b/dolphin/src/views/draganddrophelper.cpp
index 83673ad..2cd1e86 100644
--- a/dolphin/src/views/draganddrophelper.cpp
+++ b/dolphin/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/dolphin/src/views/draganddrophelper.h b/dolphin/src/views/draganddrophelper.h
index 8838648..ac16f7c 100644
--- a/dolphin/src/views/draganddrophelper.h
+++ b/dolphin/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,