If the user has pressed the Shift- or Control-key during the
rubberband selection, the previous selection should not be cleared.
#include "kitemlistrubberband_p.h"
#include "kitemlistselectionmanager.h"
#include "kitemlistrubberband_p.h"
#include "kitemlistselectionmanager.h"
#include <QEvent>
#include <QGraphicsSceneEvent>
#include <QEvent>
#include <QGraphicsSceneEvent>
rubberBandRect.translate(-m_view->offset(), 0);
}
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
QSet<int> selectedItems;
// Select all visible items that intersect with the rubberband
}
} while (!selectionFinished);
}
} while (!selectionFinished);
- m_selectionManager->setSelectedItems(selectedItems);
+ m_selectionManager->setSelectedItems(selectedItems + previousSelectedItems);
}
#include "kitemlistcontroller.moc"
}
#include "kitemlistcontroller.moc"