From: Peter Penz Date: Sat, 20 Aug 2011 21:11:55 +0000 (+0200) Subject: Respect Shift- and Control-key for the rubberband selection X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/2f0ceedae088158b8af24a5e94500a7d1c0edecb 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. --- 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 #include #include @@ -576,6 +577,17 @@ void KItemListController::slotRubberBandChanged() rubberBandRect.translate(-m_view->offset(), 0); } + QSet 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 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"