]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistcontroller.cpp
selection: fix rubberband vertices
[dolphin.git] / src / kitemviews / kitemlistcontroller.cpp
index 5929176774e5e569f6a23a343d54dc17938479f1..be7a63e0993b43b16e0b5e8564fdb568999034d7 100644 (file)
@@ -654,11 +654,6 @@ bool KItemListController::mouseMoveEvent(QGraphicsSceneMouseEvent *event, const
 
             if (m_view->scrollOrientation() == Qt::Vertical) {
                 endPos.ry() += m_view->scrollOffset();
-                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->scrollOffset();
             }
@@ -1095,13 +1090,15 @@ void KItemListController::tapAndHoldTriggered(QGestureEvent *event, const QTrans
         }
         const QPointF pressedMousePos = transform.map(event->mapToGraphicsScene(tap->position()));
         m_pressedIndex = m_view->itemAt(pressedMousePos);
-        if (m_pressedIndex.has_value() && !m_selectionManager->isSelected(m_pressedIndex.value())) {
-            m_selectionManager->clearSelection();
-            m_selectionManager->setSelected(m_pressedIndex.value());
+        if (m_pressedIndex.has_value()) {
+            if (!m_selectionManager->isSelected(m_pressedIndex.value())) {
+                m_selectionManager->clearSelection();
+                m_selectionManager->setSelected(m_pressedIndex.value());
+            }
             if (!m_selectionMode) {
                 Q_EMIT selectionModeChangeRequested(true);
             }
-        } else if (!m_pressedIndex.has_value()) {
+        } else {
             m_selectionManager->clearSelection();
             startRubberBand();
         }
@@ -1300,9 +1297,9 @@ void KItemListController::slotRubberBandChanged()
 
         const QRectF widgetRect = m_view->itemRect(index);
         if (widgetRect.intersects(rubberBandRect)) {
-            const QRectF iconRect = widget->iconRect().translated(widgetRect.topLeft());
-            const QRectF textRect = widget->textRect().translated(widgetRect.topLeft());
-            if (iconRect.intersects(rubberBandRect) || textRect.intersects(rubberBandRect)) {
+            // Select the full row intersecting with the rubberband rectangle
+            const QRectF selectionRect = widget->selectionRect().translated(widgetRect.topLeft());
+            if (selectionRect.intersects(rubberBandRect)) {
                 selectedItems.insert(index);
             }
         }
@@ -1807,11 +1804,6 @@ void KItemListController::startRubberBand()
         QPoint startPos = m_view->transform().map(m_view->scene()->views().first()->mapFromGlobal(m_pressedMouseGlobalPos.toPoint()));
         if (m_view->scrollOrientation() == Qt::Vertical) {
             startPos.ry() += m_view->scrollOffset();
-            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->scrollOffset();
         }