mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-19 16:31:21 +00:00
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.
This commit is contained in:
parent
c9f4e1baae
commit
2f0ceedae0
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue