diff options
| author | Peter Penz <[email protected]> | 2011-08-20 23:11:55 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2011-08-20 23:12:54 +0200 |
| commit | 2f0ceedae088158b8af24a5e94500a7d1c0edecb (patch) | |
| tree | 68439bf56f08e347f1443a8d177e2fa2ceb3280e /src | |
| parent | c9f4e1baae0822d0af5b5bf4d4e4af870fcb664f (diff) | |
Respect Shift- and Control-key for the rubberband selection
If the user has pressed the Shift- or Control-key during the
rubberband selection, the previous selection should not be cleared.
Diffstat (limited to 'src')
| -rw-r--r-- | src/kitemviews/kitemlistcontroller.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 50c39c18b..92a14b23d 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -26,6 +26,7 @@ #include "kitemlistrubberband_p.h" #include "kitemlistselectionmanager.h" +#include <QApplication> #include <QEvent> #include <QGraphicsSceneEvent> @@ -576,6 +577,17 @@ void KItemListController::slotRubberBandChanged() rubberBandRect.translate(-m_view->offset(), 0); } + QSet<int> previousSelectedItems; + if (m_selectionManager->hasSelection()) { + // Don't clear the current selection in case if the user pressed the + // Shift- or Control-key during the rubberband selection + const bool shiftOrControlPressed = QApplication::keyboardModifiers() & Qt::ShiftModifier || + QApplication::keyboardModifiers() & Qt::ControlModifier; + if (shiftOrControlPressed) { + previousSelectedItems = m_selectionManager->selectedItems(); + } + } + QSet<int> selectedItems; // Select all visible items that intersect with the rubberband @@ -619,7 +631,7 @@ void KItemListController::slotRubberBandChanged() } } while (!selectionFinished); - m_selectionManager->setSelectedItems(selectedItems); + m_selectionManager->setSelectedItems(selectedItems + previousSelectedItems); } #include "kitemlistcontroller.moc" |
