diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2010-02-12 18:33:01 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2010-02-12 18:33:01 (GMT) |
commit | ba1d67e35a8493a5a035f4f26970799e50661a36 (patch) | |
tree | afe039e48b8d9838361a2f11e996b0d5c433257e /src | |
parent | 62d585e8ec6c09406fa28f9edf29b56b2d67c739 (diff) | |
download | Qt-ba1d67e35a8493a5a035f4f26970799e50661a36.zip Qt-ba1d67e35a8493a5a035f4f26970799e50661a36.tar.gz Qt-ba1d67e35a8493a5a035f4f26970799e50661a36.tar.bz2 |
Fix scrolling backwards when pathItemCount != model.count
Also fixes
-Scrolling backwards when model.count != 0 mod pathItemCount
-A minor typo in a comment
Task-number: QTBUG-6865
Reviewed-by: Martin Jones
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicspathview.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicspathview.cpp b/src/declarative/graphicsitems/qmlgraphicspathview.cpp index 85e87eb..6718d25 100644 --- a/src/declarative/graphicsitems/qmlgraphicspathview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspathview.cpp @@ -910,11 +910,16 @@ void QmlGraphicsPathViewPrivate::snapToCurrent() //Rounds is the number of times round to make the current item visible int rounds = itemIndex / items.count(); - int otherWayRounds = (model->count() - (itemIndex)) / items.count() + 1; + int otherWayRounds = (model->count() - (itemIndex)) / items.count(); if (otherWayRounds < rounds) rounds = -otherWayRounds; itemIndex += pathOffset; + if(model->count() % items.count() && itemIndex - model->count() + items.count() > 0){ + //When model.count() is not a multiple of pathItemCount we need to manually + //fix the index so that going backwards one step works correctly. + itemIndex = itemIndex - model->count() + items.count(); + } itemIndex %= items.count(); qreal targetOffset = qmlMod(100 + (snapPos*100) - 100.0 * itemIndex / items.count(), qreal(100.0)); @@ -928,7 +933,7 @@ void QmlGraphicsPathViewPrivate::snapToCurrent() moveOffset.setValue(_offset); if (rounds!=0){ - //Compensate if the targetOffset would bring the target it from off the screen + //Compensate if the targetOffset would bring the target in from off the screen qreal distance = targetOffset - _offset; if (distance <= -50) rounds--; |