From 136c8210cc98bc6d9b17fd4d517d9d399f30e6c2 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 30 Jul 2009 16:58:42 +1000 Subject: Don't bounce around when removing the current item. --- src/declarative/fx/qfxlistview.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 3d97dfa..a78fed5 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -278,6 +278,18 @@ public: return -1; } + int lastVisibleIndex() const { + int lastIndex = -1; + for (int i = visibleItems.count()-1; i >= 0; --i) { + FxListItem *listItem = visibleItems.at(i); + if (listItem->index != -1) { + lastIndex = listItem->index; + break; + } + } + return lastIndex; + } + // map a model index to visibleItems index. // These may differ if removed items are still present in the visible list, // e.g. doing a removal animation @@ -542,7 +554,7 @@ void QFxListViewPrivate::layout() pos += item->size(); } // move current item if it is after the visible items. - if (currentItem && currentIndex > visibleItems.last()->index) + if (currentItem && currentIndex > lastVisibleIndex()) currentItem->setPosition(currentItem->position() + (visibleItems.last()->endPosition() - oldEnd)); } if (!isValid()) @@ -647,7 +659,8 @@ void QFxListViewPrivate::createHighlight() const QLatin1String posProp(orient == Qt::Vertical ? "y" : "x"); highlightPosAnimator = new QmlFollow(q); highlightPosAnimator->setTarget(QmlMetaProperty(highlight->item, posProp)); - highlightPosAnimator->setSpring(3); + highlightPosAnimator->setEpsilon(0.25); + highlightPosAnimator->setSpring(2.5); highlightPosAnimator->setDamping(0.3); highlightPosAnimator->setEnabled(autoHighlight); const QLatin1String sizeProp(orient == Qt::Vertical ? "height" : "width"); -- cgit v0.12