X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/894232ebda5b2cf155a4f4e5bf1287eb700faa18..ca0a2c0cb286ef36dfd44ea9ed0816f862c523b7:/src/kitemviews/kitemlistcontroller.cpp diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 645b2d34a..76f7fa1cd 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -251,7 +251,15 @@ bool KItemListController::keyPressEvent(QKeyEvent* event) 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); } @@ -545,7 +553,7 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const 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()) { @@ -795,12 +803,10 @@ bool KItemListController::dragMoveEvent(QGraphicsSceneDragDropEvent* event, cons if (m_model->supportsDropping(index)) { 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 + // The model supports inserting of items on + // the given index. Assure that a drop-indicator // is shown by the view. - const int dropIndex = m_view->showDropIndicator(pos); - Q_UNUSED(dropIndex); // TODO + m_view->showDropIndicator(pos); } emit itemHovered(index); @@ -825,8 +831,15 @@ bool KItemListController::dropEvent(QGraphicsSceneDragDropEvent* event, const QT m_view->setAutoScroll(false); const QPointF pos = transform.map(event->pos()); - const int index = m_view->itemAt(pos); - emit itemDropEvent(index, event); + if (m_model->sortRole().isEmpty()) { + // The model supports inserting of items on + // a given index. + const int dropIndex = m_view->showDropIndicator(pos); + m_view->hideDropIndicator(); + emit itemDropEvent(dropIndex, event); + } else { + emit itemDropEvent(m_view->itemAt(pos), event); + } return true; } @@ -1071,9 +1084,7 @@ void KItemListController::startDragging() 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);