From: Peter Penz Date: Sat, 20 Aug 2011 12:20:08 +0000 (+0200) Subject: Respect rubberband direction when autoscrolling X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/afcb8cd53c31ef16685f9b6fed15abada14a3d8c Respect rubberband direction when autoscrolling The autoscrolling should not be triggered if the rubberband direction is different from the autoscroll direction --- diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp index f6cfed984..9189cbda3 100644 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@ -785,9 +785,27 @@ void KItemListView::triggerAutoScrolling() } const int inc = calculateAutoScrollingIncrement(pos, visibleSize); - if (inc != 0) { - emit scrollTo(offset() + inc); + if (inc == 0) { + // The mouse position is not above an autoscroll margin + return; } + + if (m_rubberBand->isActive()) { + // If a rubberband selection is ongoing the autoscrolling may only get triggered + // if the direction of the rubberband is similar to the autoscroll direction. + + const qreal minDiff = 4; // Ignore any autoscrolling if the rubberband is very small + const qreal diff = (scrollOrientation() == Qt::Vertical) + ? m_rubberBand->endPosition().y() - m_rubberBand->startPosition().y() + : m_rubberBand->endPosition().x() - m_rubberBand->startPosition().x(); + if (qAbs(diff) < minDiff || (inc < 0 && diff > 0) || (inc > 0 && diff < 0)) { + // The rubberband direction is different from the scroll direction (e.g. the rubberband has + // been moved up although the autoscroll direction might be down) + return; + } + } + + emit scrollTo(offset() + inc); } void KItemListView::setController(KItemListController* controller)