┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kitemlistview.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2011-08-20 14:20:08 +0200
committerPeter Penz <[email protected]>2011-08-20 14:21:05 +0200
commitafcb8cd53c31ef16685f9b6fed15abada14a3d8c (patch)
tree53b44139d863b7e14d2152c177ae12ae91b32f39 /src/kitemviews/kitemlistview.cpp
parent074acd8009765f5e6ad5cb7f1887d50f4aea5a58 (diff)
Respect rubberband direction when autoscrolling
The autoscrolling should not be triggered if the rubberband direction is different from the autoscroll direction
Diffstat (limited to 'src/kitemviews/kitemlistview.cpp')
-rw-r--r--src/kitemviews/kitemlistview.cpp22
1 files changed, 20 insertions, 2 deletions
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)