summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBłażej Szczygieł <spaz16@wp.pl>2017-07-13 22:19:31 +0200
committerBłażej Szczygieł <spaz16@wp.pl>2017-07-21 16:01:50 +0000
commitf9afae9e08986e84c5c4028fd09a849e92378300 (patch)
treeefcd571bd06b02b5151edc1b227cbf5d3d14cf63
parentd819d6864a52d78cb86be3f2d3250a2c51835aeb (diff)
QListView: Fix item movement in icon mode
Since b13aa15e1007a1b5ed61049bbd9ef8f95b6d12a5 the event must not be accepted when calling "canDrop()" method. Inside it "dropOn()" method is called which requires not accepted event. Otherwise the event will be ignored later in "QListView::dragMoveEvent()". On next movement it will be accepted again - the event is now ignored, so "dropOn() method will work properly. If "filterDragMoveEvent()" returns false for any reason, the event acceptance is not changed - the same behavior as before. Task-number: QTBUG-61951 Change-Id: I2d49ce5b15300c42e2efc745e8e32d3d17f34a2f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
-rw-r--r--src/widgets/itemviews/qlistview.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 83962f3bbc..9e959c8e1e 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -2814,11 +2814,17 @@ bool QIconModeViewBase::filterDragLeaveEvent(QDragLeaveEvent *e)
bool QIconModeViewBase::filterDragMoveEvent(QDragMoveEvent *e)
{
- if (e->source() != qq || !dd->canDrop(e))
- return false;
+ const bool wasAccepted = e->isAccepted();
// ignore by default
e->ignore();
+
+ if (e->source() != qq || !dd->canDrop(e)) {
+ // restore previous acceptance on failure
+ e->setAccepted(wasAccepted);
+ return false;
+ }
+
// get old dragged items rect
QRect itemsRect = this->itemsRect(draggedItems);
viewport()->update(itemsRect.translated(draggedItemsDelta()));