diff options
| author | Tomasz Kot <[email protected]> | 2025-11-28 16:11:00 +0100 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2026-01-21 09:01:28 +0000 |
| commit | 843d10ae2ab6a7f2c6f69b63fa278fdd6162254c (patch) | |
| tree | ab8a57d633493ead07320e8113e268126b96c5b4 /src/kitemviews/kitemlistcontroller.cpp | |
| parent | d04dc824270891b7e3d617b5bb7b5ed668388fd2 (diff) | |
Add keyboard anchor assignments to mouse events
The mouse events need to modify the keyboard anchor assignments as well,
because selecting an item with a mouse and then navigating with keyboard
wouldn't follow the same selection.
BUG: 508609
Diffstat (limited to 'src/kitemviews/kitemlistcontroller.cpp')
| -rw-r--r-- | src/kitemviews/kitemlistcontroller.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index d889deb4e..8723ba4d9 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -534,6 +534,8 @@ void KItemListController::slotChangeCurrentItem(const QString &text, bool search } m_selectionManager->setCurrentItem(index); + m_keyboardAnchorIndex = index; + m_keyboardAnchorPos = keyboardAnchorPos(index); if (m_selectionBehavior != NoSelection) { if (!m_selectionMode) { // Don't clear the selection in selection mode. @@ -654,6 +656,8 @@ bool KItemListController::mouseMoveEvent(QGraphicsSceneMouseEvent *event, const m_selectionManager->endAnchoredSelection(); m_selectionManager->setCurrentItem(newCurrent.value()); m_selectionManager->beginAnchoredSelection(newCurrent.value()); + m_keyboardAnchorIndex = newCurrent.value(); + m_keyboardAnchorPos = keyboardAnchorPos(newCurrent.value()); } if (m_view->scrollOrientation() == Qt::Vertical) { @@ -1625,6 +1629,8 @@ bool KItemListController::onPress(const QPointF &pos, const Qt::KeyboardModifier m_selectionManager->endAnchoredSelection(); m_selectionManager->setCurrentItem(m_pressedIndex.value()); m_selectionManager->beginAnchoredSelection(m_pressedIndex.value()); + m_keyboardAnchorIndex = m_pressedIndex.value(); + m_keyboardAnchorPos = keyboardAnchorPos(m_pressedIndex.value()); return true; } @@ -1636,6 +1642,8 @@ bool KItemListController::onPress(const QPointF &pos, const Qt::KeyboardModifier // the current item and start a new anchored selection now. m_selectionManager->setCurrentItem(m_pressedIndex.value()); m_selectionManager->beginAnchoredSelection(m_pressedIndex.value()); + m_keyboardAnchorIndex = m_pressedIndex.value(); + m_keyboardAnchorPos = keyboardAnchorPos(m_pressedIndex.value()); return true; } @@ -1675,6 +1683,8 @@ bool KItemListController::onPress(const QPointF &pos, const Qt::KeyboardModifier m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Toggle); m_selectionManager->setCurrentItem(m_pressedIndex.value()); m_selectionManager->beginAnchoredSelection(m_pressedIndex.value()); + m_keyboardAnchorIndex = m_pressedIndex.value(); + m_keyboardAnchorPos = keyboardAnchorPos(m_pressedIndex.value()); } if (leftClick) { row->setPressed(true); @@ -1743,6 +1753,8 @@ bool KItemListController::onPress(const QPointF &pos, const Qt::KeyboardModifier } m_selectionManager->setCurrentItem(m_pressedIndex.value()); + m_keyboardAnchorIndex = m_pressedIndex.value(); + m_keyboardAnchorPos = keyboardAnchorPos(m_pressedIndex.value()); switch (m_selectionBehavior) { case NoSelection: |
