┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kitemlistcontroller.cpp
diff options
context:
space:
mode:
authorFelix Ernst <[email protected]>2022-04-04 12:39:37 +0000
committerFelix Ernst <[email protected]>2022-04-04 12:39:37 +0000
commit2de8f4c0fb2141f68400327a4f87eefa71d81e3c (patch)
treee1737469886ef0aed4f2f5f50048b1b309c72596 /src/kitemviews/kitemlistcontroller.cpp
parenta4f9974daf1e533c39f67129b85193ad4d47e5ad (diff)
Improve details mode ctrl-press rubberband creation
Since d3839617193e92463806580699caa595c892b8a6 dragging the highlighted row of already selected items in the details view mode will begin a drag operation of all selected items. As a unintended side-effect of this change, dragging the row of a previously unselected item while holding the control key would also begin a drag operation. After this commit, dragging the row of a previously unselected item while holding the control key in details view mode will instead create a rubberband. Ctrl-dragging the item's icon or text directly will drag the item as expected. With this change, using multiple rubberbands to select scattered items among a list of items should be as convenient as it was previously. BUG: 452181
Diffstat (limited to 'src/kitemviews/kitemlistcontroller.cpp')
-rw-r--r--src/kitemviews/kitemlistcontroller.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp
index 9f54fad2c..7ef37481d 100644
--- a/src/kitemviews/kitemlistcontroller.cpp
+++ b/src/kitemviews/kitemlistcontroller.cpp
@@ -1600,9 +1600,20 @@ bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, c
case MultiSelection:
if (controlPressed && !shiftPressed) {
- m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Toggle);
- m_selectionManager->beginAnchoredSelection(m_pressedIndex.value());
- createRubberBand = false; // multi selection, don't propagate any further
+ // A mouse button press is happening on an item while control is pressed. This either means a user wants to:
+ // - toggle the selection of item(s) or
+ // - they want to begin a drag on the item(s) to copy them.
+ // We rule out the latter, if the item is not clicked directly and was unselected previously.
+ const auto row = m_view->m_visibleItems.value(m_pressedIndex.value());
+ const auto mappedPos = row->mapFromItem(m_view, pos);
+ if (!row->iconRect().contains(mappedPos) && !row->textRect().contains(mappedPos) && !pressedItemAlreadySelected) {
+ createRubberBand = true;
+ } else {
+ m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Toggle);
+ m_selectionManager->beginAnchoredSelection(m_pressedIndex.value());
+ createRubberBand = false; // multi selection, don't propagate any further
+ // This will be the start of an item drag-to-copy operation if the user now moves the mouse before releasing the mouse button.
+ }
} else if (!shiftPressed || !m_selectionManager->isAnchoredSelectionActive()) {
// Select the pressed item and start a new anchored selection
m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Select);