X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/2e588733c759cccd2d86e34a3a394b9a8ab0c800..40cc5f665d:/src/kitemviews/kitemlistcontroller.cpp diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index ce96cab6c..955e418e8 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -53,7 +52,6 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v m_pressedIndex(std::nullopt), m_pressedMousePos(), m_autoActivationTimer(nullptr), - m_longPressDetectionTimer(nullptr), m_swipeGesture(Qt::CustomGesture), m_twoFingerTapGesture(Qt::CustomGesture), m_oldSelection(), @@ -72,15 +70,6 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v m_autoActivationTimer->setInterval(-1); connect(m_autoActivationTimer, &QTimer::timeout, this, &KItemListController::slotAutoActivationTimeout); - m_longPressDetectionTimer = new QTimer(this); - m_longPressDetectionTimer->setSingleShot(true); - m_longPressDetectionTimer->setInterval(QGuiApplication::styleHints()->mousePressAndHoldInterval()); - connect(m_longPressDetectionTimer, &QTimer::timeout, this, [this]() { - if (!m_selectionMode) { - Q_EMIT selectionModeChangeRequested(true); - } - }); - setModel(model); setView(view); @@ -430,10 +419,9 @@ bool KItemListController::keyPressEvent(QKeyEvent* event) } case Qt::Key_Escape: - if (m_selectionMode && m_selectionManager->selectedItems().count() < 1) { + if (m_selectionMode) { Q_EMIT selectionModeChangeRequested(false); - } - if (m_selectionBehavior != SingleSelection) { + } else if (m_selectionBehavior != SingleSelection) { m_selectionManager->clearSelection(); } m_keyboardManager->cancelSearch(); @@ -602,9 +590,6 @@ bool KItemListController::mouseMoveEvent(QGraphicsSceneMouseEvent* event, const } const QPointF pos = transform.map(event->pos()); - if ((pos - m_pressedMousePos).manhattanLength() >= QApplication::startDragDistance()) { - m_longPressDetectionTimer->stop(); - } if (m_pressedIndex.has_value() && !m_view->rubberBand()->isActive()) { // Check whether a dragging should be started @@ -668,8 +653,6 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con m_view->m_tapAndHoldIndicator->setActive(false); } - m_longPressDetectionTimer->stop(); - KItemListRubberBand* rubberBand = m_view->rubberBand(); if (event->source() == Qt::MouseEventSynthesizedByQt && !rubberBand->isActive() && m_isTouchEvent) { return false; @@ -1059,8 +1042,6 @@ void KItemListController::tapTriggered(QTapGesture* tap, const QTransform& trans m_pressedIndex = m_view->itemAt(m_pressedMousePos); if (m_dragActionOrRightClick) { - onPress(tap->hotSpot().toPoint(), tap->position().toPoint(), Qt::NoModifier, Qt::RightButton); - onRelease(transform.map(tap->position()), Qt::NoModifier, Qt::RightButton, false); m_dragActionOrRightClick = false; } else { @@ -1091,6 +1072,9 @@ void KItemListController::tapAndHoldTriggered(QGestureEvent* event, const QTrans if (m_pressedIndex.has_value() && !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()) { m_selectionManager->clearSelection(); startRubberBand(); @@ -1554,10 +1538,6 @@ bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, c const bool leftClick = buttons & Qt::LeftButton; const bool rightClick = buttons & Qt::RightButton; - if (leftClick) { - m_longPressDetectionTimer->start(); - } - // The previous selection is cleared if either // 1. The selection mode is SingleSelection, or // 2. the selection mode is MultiSelection, and *none* of the following conditions are met: @@ -1783,7 +1763,7 @@ bool KItemListController::onRelease(const QPointF& pos, const Qt::KeyboardModifi } else { const bool singleClickActivation = m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced; if (!singleClickActivation) { - emitItemActivated = touch; + emitItemActivated = touch && !m_selectionMode; } else { // activate on single click only if we didn't come from a rubber band release emitItemActivated = !rubberBandRelease;