diff options
| author | Peter Penz <[email protected]> | 2011-08-20 23:26:07 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2011-08-20 23:27:23 +0200 |
| commit | 6a228cdbd94ae8cb8215d53187328c54cbc050bd (patch) | |
| tree | 30adae6e5844a917db0e640ece53e9f039ba75e7 /src/kitemviews/kitemlistcontroller.cpp | |
| parent | 2f0ceedae088158b8af24a5e94500a7d1c0edecb (diff) | |
Fix rubberband-issue in combination with Shift- and Control-key
The old selection must be remembered before starting the rubberband
selection, otherwise it would not be possible anymore to deselect
items that have been selected by the rubberband itself.
Diffstat (limited to 'src/kitemviews/kitemlistcontroller.cpp')
| -rw-r--r-- | src/kitemviews/kitemlistcontroller.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 92a14b23d..beb5b5c0a 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -38,7 +38,8 @@ KItemListController::KItemListController(QObject* parent) : m_model(0), m_view(0), m_selectionManager(new KItemListSelectionManager(this)), - m_pressedIndex(-1) + m_pressedIndex(-1), + m_oldSelection() { } @@ -294,6 +295,8 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const } else { startPos.rx() += m_view->offset(); } + + m_oldSelection = m_selectionManager->selectedItems(); rubberBand->setStartPosition(startPos); rubberBand->setEndPosition(startPos); rubberBand->setActive(true); @@ -338,6 +341,7 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con if (rubberBand->isActive()) { disconnect(rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandChanged())); rubberBand->setActive(false); + m_oldSelection.clear(); m_pressedIndex = -1; return false; } @@ -577,14 +581,13 @@ 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 + if (!m_oldSelection.isEmpty()) { + // Clear the old selection that was available before the rubberband has + // been activated in case if no Shift- or Control-key are pressed const bool shiftOrControlPressed = QApplication::keyboardModifiers() & Qt::ShiftModifier || QApplication::keyboardModifiers() & Qt::ControlModifier; - if (shiftOrControlPressed) { - previousSelectedItems = m_selectionManager->selectedItems(); + if (!shiftOrControlPressed) { + m_oldSelection.clear(); } } @@ -631,7 +634,7 @@ void KItemListController::slotRubberBandChanged() } } while (!selectionFinished); - m_selectionManager->setSelectedItems(selectedItems + previousSelectedItems); + m_selectionManager->setSelectedItems(selectedItems + m_oldSelection); } #include "kitemlistcontroller.moc" |
