URL To paste - | raw -
Fri Feb 02 2018 23:21:58 GMT+0000 (Coordinated Universal Time)
diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp
index 130936488..b5438e5d4 100644
--- a/src/kitemviews/kitemlistcontroller.cpp
+++ b/src/kitemviews/kitemlistcontroller.cpp
@@ -46,6 +46,7 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v
m_singleClickActivationEnforced(false),
m_selectionTogglePressed(false),
m_clearSelectionIfItemsAreNotDragged(false),
+ m_currentDropAcceptState(false),
m_selectionBehavior(NoSelection),
m_autoActivationBehavior(ActivationAndExpansion),
m_mouseDoubleClickAction(ActivateItemOnly),
@@ -849,6 +850,9 @@ bool KItemListController::dragEnterEvent(QGraphicsSceneDragDropEvent* event, con
{
Q_UNUSED(event);
Q_UNUSED(transform);
+
+ m_currentDropAcceptState = !DragAndDropHelper::urlListMatchesUrl(event->mimeData()->urls(), m_model->directory());
+
return false;
}
@@ -857,6 +861,8 @@ bool KItemListController::dragLeaveEvent(QGraphicsSceneDragDropEvent* event, con
Q_UNUSED(event);
Q_UNUSED(transform);
+ m_currentDropAcceptState = false;
+
m_autoActivationTimer->stop();
m_view->setAutoScroll(false);
m_view->hideDropIndicator();
@@ -876,7 +882,6 @@ bool KItemListController::dragMoveEvent(QGraphicsSceneDragDropEvent* event, cons
}
- QUrl hoveredDir = m_model->directory();
KItemListWidget* oldHoveredWidget = hoveredWidget();
const QPointF pos = transform.map(event->pos());
@@ -901,7 +906,7 @@ bool KItemListController::dragMoveEvent(QGraphicsSceneDragDropEvent* event, cons
const int index = newHoveredWidget->index();
if (m_model->isDir(index)) {
- hoveredDir = m_model->url(index);
+ m_currentDropAcceptState = !DragAndDropHelper::urlListMatchesUrl(event->mimeData()->urls(), m_model->url(index));
}
if (!droppingBetweenItems) {
@@ -929,7 +934,7 @@ bool KItemListController::dragMoveEvent(QGraphicsSceneDragDropEvent* event, cons
m_view->hideDropIndicator();
}
- event->setAccepted(!DragAndDropHelper::urlListMatchesUrl(event->mimeData()->urls(), hoveredDir));
+ event->setAccepted(m_currentDropAcceptState);
return false;
}
diff --git a/src/kitemviews/kitemlistcontroller.h b/src/kitemviews/kitemlistcontroller.h
index 3de5edece..c9ad4b7d4 100644
--- a/src/kitemviews/kitemlistcontroller.h
+++ b/src/kitemviews/kitemlistcontroller.h
@@ -311,6 +311,7 @@ private:
bool m_singleClickActivationEnforced;
bool m_selectionTogglePressed;
bool m_clearSelectionIfItemsAreNotDragged;
+ bool m_currentDropAcceptState;
SelectionBehavior m_selectionBehavior;
AutoActivationBehavior m_autoActivationBehavior;
MouseDoubleClickAction m_mouseDoubleClickAction;
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index e40e49d6e..11f542962 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -1071,6 +1071,7 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
event->mimeData(),
event->buttons(),
event->modifiers());
+ dropEvent.setAccepted(event->isAccepted());
dropUrls(destUrl, &dropEvent, this);
setActive(true);
diff --git a/src/views/draganddrophelper.cpp b/src/views/draganddrophelper.cpp
index e944227df..7bd004052 100644
--- a/src/views/draganddrophelper.cpp
+++ b/src/views/draganddrophelper.cpp
@@ -39,6 +39,11 @@ bool DragAndDropHelper::urlListMatchesUrl(const QList<QUrl>& urls, const QUrl& d
KIO::DropJob* DragAndDropHelper::dropUrls(const QUrl& destUrl, QDropEvent* event, QWidget* window)
{
+ // The drop event isn't accpeted. Could for instance be because of dropping on itself.
+ if (!event->isAccepted()) {
+ return nullptr;
+ }
+
const QMimeData* mimeData = event->mimeData();
if (mimeData->hasFormat(QStringLiteral("application/x-kde-ark-dndextract-service")) &&
mimeData->hasFormat(QStringLiteral("application/x-kde-ark-dndextract-path"))) {
@@ -50,10 +55,6 @@ KIO::DropJob* DragAndDropHelper::dropUrls(const QUrl& destUrl, QDropEvent* event
message.setArguments({destUrl.toDisplayString(QUrl::PreferLocalFile)});
QDBusConnection::sessionBus().call(message);
} else {
- if (urlListMatchesUrl(event->mimeData()->urls(), destUrl)) {
- return nullptr;
- }
-
// Drop into a directory or a desktop-file
KIO::DropJob *job = KIO::drop(event, destUrl);
KJobWidgets::setWindow(job, window);