diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-10-29 03:57:51 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-10-29 03:57:51 (GMT) |
commit | c0a13ae7fd61dcd7a56e068ca6bb7bf44400bbeb (patch) | |
tree | 2b9c6432bf00df15f5ce4556465236a0c5cdad2a /src | |
parent | 6c548e21f48b07d55187952ff21cbbc23fdd3927 (diff) | |
download | Qt-c0a13ae7fd61dcd7a56e068ca6bb7bf44400bbeb.zip Qt-c0a13ae7fd61dcd7a56e068ca6bb7bf44400bbeb.tar.gz Qt-c0a13ae7fd61dcd7a56e068ca6bb7bf44400bbeb.tar.bz2 |
Avoid unnecessary viewport scrolling when bringing currentItem into view.
Task-number: QT-2399
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/fx/qfxlistview.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index f9ae0c0..18c3062 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -1679,37 +1679,46 @@ void QFxListView::trackedPositionChanged() return; if (!isFlicking() && !d->moving && d->moveReason != QFxListViewPrivate::Mouse) { const qreal trackedPos = d->trackedItem->position(); + const qreal viewPos = d->position(); if (d->haveHighlightRange) { if (d->highlightRange == StrictlyEnforceRange) { - qreal pos = d->position(); + qreal pos = viewPos; if (trackedPos > pos + d->highlightRangeEnd - d->trackedItem->size()) pos = trackedPos - d->highlightRangeEnd + d->trackedItem->size(); if (trackedPos < pos + d->highlightRangeStart) pos = trackedPos - d->highlightRangeStart; d->setPosition(pos); } else { - qreal pos = d->position(); + qreal pos = viewPos; if (trackedPos < d->startPosition() + d->highlightRangeStart) { pos = d->startPosition(); } else if (d->trackedItem->endPosition() > d->endPosition() - d->size() + d->highlightRangeEnd) { pos = d->endPosition() - d->size(); } else { - if (trackedPos < d->position() + d->highlightRangeStart) { + if (trackedPos < viewPos + d->highlightRangeStart) { pos = trackedPos - d->highlightRangeStart; - } else if (trackedPos > d->position() + d->highlightRangeEnd - d->trackedItem->size()) { + } else if (trackedPos > viewPos + d->highlightRangeEnd - d->trackedItem->size()) { pos = trackedPos - d->highlightRangeEnd + d->trackedItem->size(); } } d->setPosition(pos); } } else { - if (trackedPos < d->position()) { - d->setPosition(trackedPos); + if (trackedPos < viewPos && d->currentItem->position() < viewPos) { + d->setPosition(d->currentItem->position() < trackedPos ? trackedPos : d->currentItem->position()); d->fixupPosition(); - } else if (d->trackedItem->endPosition() > d->position() + d->size()) { - qreal pos = d->trackedItem->endPosition() - d->size(); - if (d->trackedItem->size() > d->size()) - pos = trackedPos; + } else if (d->trackedItem->endPosition() > viewPos + d->size() + && d->currentItem->endPosition() > viewPos + d->size()) { + qreal pos; + if (d->trackedItem->endPosition() < d->currentItem->endPosition()) { + pos = d->trackedItem->endPosition() - d->size(); + if (d->trackedItem->size() > d->size()) + pos = trackedPos; + } else { + pos = d->currentItem->endPosition() - d->size(); + if (d->currentItem->size() > d->size()) + pos = d->currentItem->position(); + } d->setPosition(pos); d->fixupPosition(); } |