case Qt::Key_Left:
if (index > 0) {
- --index;
+ const int expandedParentsCount = m_model->expandedParentsCount(index);
+ if (expandedParentsCount == 0) {
+ --index;
+ } else {
+ // Go to the parent of the current item.
+ do {
+ --index;
+ } while (index > 0 && m_model->expandedParentsCount(index) == expandedParentsCount);
+ }
m_keyboardAnchorIndex = index;
m_keyboardAnchorPos = keyboardAnchorPos(index);
}
return;
}
- if (m_model->supportsDropping(index)) {
+ /* m_view->isUnderMouse() fixes a bug in the Folder-View-Panel and in the
+ * Places-Panel.
+ *
+ * Bug: When you drag a file onto a Folder-View-Item or a Places-Item and
+ * then move away before the auto-activation timeout triggers, than the
+ * item still becomes activated/expanded.
+ *
+ * See Bug 293200 and 305783
+ */
+ if (m_model->supportsDropping(index) && m_view->isUnderMouse()) {
if (m_view->supportsItemExpanding() && m_model->isExpandable(index)) {
const bool expanded = m_model->isExpanded(index);
m_model->setExpanded(index, !expanded);
break;
case MultiSelection:
- if (controlPressed) {
+ if (controlPressed && !shiftPressed) {
m_selectionManager->setSelected(m_pressedIndex, 1, KItemListSelectionManager::Toggle);
m_selectionManager->beginAnchoredSelection(m_pressedIndex);
} else if (!shiftPressed || !m_selectionManager->isAnchoredSelectionActive()) {
bool KItemListController::dragMoveEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform)
{
- Q_UNUSED(transform);
if (!m_model || !m_view) {
return false;
}
}
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 the inserting of items on
- // the given index as no sort-role has been
- // specified. Assure that a drag-indicator
- // is shown by the view.
- const int dropIndex = m_view->showDropIndicator(pos);
- Q_UNUSED(dropIndex); // TODO
- }
- 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();
+ }
}
}
}
bool KItemListController::dropEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform)
{
- Q_UNUSED(transform)
if (!m_view) {
return false;
}
m_view->setAutoScroll(false);
const QPointF pos = transform.map(event->pos());
- const int index = m_view->itemAt(pos);
- emit itemDropEvent(index, event);
+
+ int dropAboveIndex = -1;
+ if (m_model->sortRole().isEmpty()) {
+ // 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 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);
+ }
return true;
}
const QPixmap pixmap = m_view->createDragPixmap(selectedItems);
drag->setPixmap(pixmap);
- // TODO: The vertical hotspot of -24 should be replaced by the
- // height of the QCursor-pixmap.
- const QPoint hotSpot(pixmap.width() / 2, -24);
+ const QPoint hotSpot(pixmap.width() / 2, 0);
drag->setHotSpot(hotSpot);
drag->exec(Qt::MoveAction | Qt::CopyAction | Qt::LinkAction, Qt::CopyAction);