From: Martin Jones Date: Mon, 1 Aug 2011 05:00:30 +0000 (+1000) Subject: View highlight could stop tracking currentItem. X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=a1bd1690851c905d79ae694c15a04fd12a717f3e;p=konrad%2Fqtdeclarative.git View highlight could stop tracking currentItem. This happens if the currentIndex is changed while the view is moving. The only time the highlight should not move to the currentItem is in StrictlyEnforceRange mode when the user is moving the view. Change-Id: I4d04174c88cde180f9f8a01cbd33af3edbcc3d4d Fixes: QTBUG-16936 Reviewed-on: http://codereview.qt.nokia.com/2416 Reviewed-by: Bea Lam Reviewed-by: Qt Sanity Bot --- diff --git a/src/declarative/items/qsggridview.cpp b/src/declarative/items/qsggridview.cpp index 26347c1..ec22761 100644 --- a/src/declarative/items/qsggridview.cpp +++ b/src/declarative/items/qsggridview.cpp @@ -602,7 +602,8 @@ void QSGGridViewPrivate::updateHighlight() { if ((!currentItem && highlight) || (currentItem && !highlight)) createHighlight(); - if (currentItem && autoHighlight && highlight && !movingHorizontally && !movingVertically) { + bool strictHighlight = haveHighlightRange && highlightRange == QSGGridView::StrictlyEnforceRange; + if (currentItem && autoHighlight && highlight && (!strictHighlight || !pressed)) { // auto-update highlight highlightXAnimator->to = currentItem->item->x(); highlightYAnimator->to = currentItem->item->y(); @@ -1115,7 +1116,13 @@ void QSGGridView::viewportMoved() if (pos < viewPos + highlightStart) pos = viewPos + highlightStart; - static_cast(d->highlight)->setPosition(static_cast(d->highlight)->colPos(), qRound(pos)); + if (pos != d->highlight->position()) { + d->highlightXAnimator->stop(); + d->highlightYAnimator->stop(); + static_cast(d->highlight)->setPosition(static_cast(d->highlight)->colPos(), pos); + } else { + d->updateHighlight(); + } // update current index int idx = d->snapIndex(); diff --git a/src/declarative/items/qsglistview.cpp b/src/declarative/items/qsglistview.cpp index 641dd35..9c3ab2a 100644 --- a/src/declarative/items/qsglistview.cpp +++ b/src/declarative/items/qsglistview.cpp @@ -726,7 +726,8 @@ void QSGListViewPrivate::updateHighlight() { if ((!currentItem && highlight) || (currentItem && !highlight)) createHighlight(); - if (currentItem && autoHighlight && highlight && !movingHorizontally && !movingVertically) { + bool strictHighlight = haveHighlightRange && highlightRange == QSGListView::StrictlyEnforceRange; + if (currentItem && autoHighlight && highlight && (!strictHighlight || !pressed)) { // auto-update highlight FxListItemSG *listItem = static_cast(currentItem); highlightPosAnimator->to = isRightToLeft() @@ -1432,8 +1433,12 @@ void QSGListView::viewportMoved() pos = viewPos + highlightEnd - d->highlight->size(); if (pos < viewPos + highlightStart) pos = viewPos + highlightStart; - d->highlightPosAnimator->stop(); - static_cast(d->highlight)->setPosition(qRound(pos)); + if (pos != d->highlight->position()) { + d->highlightPosAnimator->stop(); + static_cast(d->highlight)->setPosition(pos); + } else { + d->updateHighlight(); + } // update current index if (FxViewItem *snapItem = d->snapItemAt(d->highlight->position())) {