#include "kitemlistrubberband_p.h"
#include "kitemlistselectionmanager.h"
+#include <QApplication>
#include <QEvent>
#include <QGraphicsSceneEvent>
QPointF startPos = pos;
if (m_view->scrollOrientation() == Qt::Vertical) {
startPos.ry() += m_view->offset();
+ if (m_view->itemSize().width() < 0) {
+ // Use a special rubberband for views that have only one column and
+ // expand the rubberband to use the whole width of the view.
+ startPos.setX(0);
+ }
} else {
startPos.rx() += m_view->offset();
}
QPointF endPos = transform.map(event->pos());
if (m_view->scrollOrientation() == Qt::Vertical) {
endPos.ry() += m_view->offset();
+ if (m_view->itemSize().width() < 0) {
+ // Use a special rubberband for views that have only one column and
+ // expand the rubberband to use the whole width of the view.
+ endPos.setX(m_view->size().width());
+ }
} else {
endPos.rx() += m_view->offset();
}
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
}
} while (!selectionFinished);
- m_selectionManager->setSelectedItems(selectedItems);
+ m_selectionManager->setSelectedItems(selectedItems + previousSelectedItems);
}
#include "kitemlistcontroller.moc"