X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/4aedb0767490989ea00251a39b8d76f1b51a4303..2f0ceedae088158b8af24a5e94500a7d1c0edecb:/src/kitemviews/kitemlistcontroller.cpp diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 31a1cfc2f..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 @@ -285,6 +286,11 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const 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(); } @@ -308,6 +314,11 @@ bool KItemListController::mouseMoveEvent(QGraphicsSceneMouseEvent* event, const 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(); } @@ -566,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 @@ -609,7 +631,7 @@ void KItemListController::slotRubberBandChanged() } } while (!selectionFinished); - m_selectionManager->setSelectedItems(selectedItems); + m_selectionManager->setSelectedItems(selectedItems + previousSelectedItems); } #include "kitemlistcontroller.moc"