diff options
Diffstat (limited to 'src/declarative/graphicsitems/qmlgraphicspathview.cpp')
-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--; |