diff options
| author | Frank Reininghaus <[email protected]> | 2012-07-12 00:27:53 +0200 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2012-07-12 00:36:32 +0200 |
| commit | cd5d20ff8a4d2c65d130ef45de5f620b0fa4859e (patch) | |
| tree | 0230ed4919b67c0762ef950ae4b98499777933b7 /src/kitemviews/kitemlistcontroller.cpp | |
| parent | cc03c5514c5f917e180c2fcb6b6b3ce991c774f8 (diff) | |
Re-implement dropping of files on folders in the Places Panel.
This resolves a regression caused by the Places Panel rewrite. There is
a small glitch left when reordering items (dragging below the last or
above the first item only shows the drop indicator when first dragging
out of the item and then back), but I prefer not to fix this glitch
right now because this would require a more intrusive change, and I do
not want to risk regressions because is not much time left to fix them
before 4.9.0 is released.
Thanks to Peter Penz for providing some advice about this issue.
CCBUG: 302557
Diffstat (limited to 'src/kitemviews/kitemlistcontroller.cpp')
| -rw-r--r-- | src/kitemviews/kitemlistcontroller.cpp | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 76f7fa1cd..88f5d9f7c 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -778,7 +778,6 @@ bool KItemListController::dragLeaveEvent(QGraphicsSceneDragDropEvent* event, con bool KItemListController::dragMoveEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform) { - Q_UNUSED(transform); if (!m_model || !m_view) { return false; } @@ -799,20 +798,23 @@ bool KItemListController::dragMoveEvent(QGraphicsSceneDragDropEvent* event, cons } if (newHoveredWidget) { + bool droppingBetweenItems = false; + if (m_model->sortRole().isEmpty()) { + // The model supports inserting items between other items. + droppingBetweenItems = (m_view->showDropIndicator(pos) >= 0); + } + const int index = newHoveredWidget->index(); - if (m_model->supportsDropping(index)) { + if (!droppingBetweenItems && m_model->supportsDropping(index)) { + // Something has been dragged on an item. + m_view->hideDropIndicator(); newHoveredWidget->setHovered(true); - } else if (m_model->sortRole().isEmpty()) { - // The model supports inserting of items on - // the given index. Assure that a drop-indicator - // is shown by the view. - m_view->showDropIndicator(pos); - } - emit itemHovered(index); + emit itemHovered(index); - if (m_autoActivationTimer->interval() >= 0) { - m_autoActivationTimer->setProperty("index", index); - m_autoActivationTimer->start(); + if (m_autoActivationTimer->interval() >= 0) { + m_autoActivationTimer->setProperty("index", index); + m_autoActivationTimer->start(); + } } } } @@ -822,7 +824,6 @@ bool KItemListController::dragMoveEvent(QGraphicsSceneDragDropEvent* event, cons bool KItemListController::dropEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform) { - Q_UNUSED(transform) if (!m_view) { return false; } @@ -831,13 +832,19 @@ bool KItemListController::dropEvent(QGraphicsSceneDragDropEvent* event, const QT m_view->setAutoScroll(false); const QPointF pos = transform.map(event->pos()); + + int dropAboveIndex = -1; if (m_model->sortRole().isEmpty()) { - // The model supports inserting of items on - // a given index. - const int dropIndex = m_view->showDropIndicator(pos); + // The model supports inserting of items between other items. + dropAboveIndex = m_view->showDropIndicator(pos); + } + + if (dropAboveIndex >= 0) { + // Something has been dropped between two items. m_view->hideDropIndicator(); - emit itemDropEvent(dropIndex, event); + emit aboveItemDropEvent(dropAboveIndex, event); } else { + // Something has been dropped on an item or on an empty part of the view. emit itemDropEvent(m_view->itemAt(pos), event); } |
