diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-07-28 15:06:02 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-28 08:39:33 +0200 |
commit | da0441aa30e1e10c1e0ac9a8cd305c1b6e63c111 (patch) | |
tree | 47ed8dd27a44689c0bfb420950faf1e26fac8dc3 /src | |
parent | 68ef13d7915fd86164b1819f7adeea22214a41b7 (diff) |
ListView doesn't show new 1st item currentItem is removed.
If the new 1st item becomes the currentItem after removal
it was positioned incorrectly because the currentItem is positioned
based on visibleIndex, which was updated after the currentItem
was updated. Move visibleIndex update before currentItem update.
Change-Id: Iaf92a41eefe7bce093e3000d17f5496dba144bcd
Fixes: QTBUG-20575
Reviewed-on: http://codereview.qt.nokia.com/2316
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/items/qsggridview.cpp | 18 | ||||
-rw-r--r-- | src/declarative/items/qsglistview.cpp | 20 | ||||
-rw-r--r-- | src/qtquick1/graphicsitems/qdeclarativegridview.cpp | 18 | ||||
-rw-r--r-- | src/qtquick1/graphicsitems/qdeclarativelistview.cpp | 20 |
4 files changed, 38 insertions, 38 deletions
diff --git a/src/declarative/items/qsggridview.cpp b/src/declarative/items/qsggridview.cpp index 214481a288..7b0e4f3e9a 100644 --- a/src/declarative/items/qsggridview.cpp +++ b/src/declarative/items/qsggridview.cpp @@ -1445,6 +1445,15 @@ void QSGGridView::itemsRemoved(int modelIndex, int count) } } + // update visibleIndex + d->visibleIndex = 0; + for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { + if ((*it)->index != -1) { + d->visibleIndex = (*it)->index; + break; + } + } + // fix current if (d->currentIndex >= modelIndex + count) { d->currentIndex -= count; @@ -1462,15 +1471,6 @@ void QSGGridView::itemsRemoved(int modelIndex, int count) emit currentIndexChanged(); } - // update visibleIndex - d->visibleIndex = 0; - for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { - if ((*it)->index != -1) { - d->visibleIndex = (*it)->index; - break; - } - } - if (removedVisible && d->visibleItems.isEmpty()) { d->timeline.clear(); if (d->itemCount == 0) { diff --git a/src/declarative/items/qsglistview.cpp b/src/declarative/items/qsglistview.cpp index 37b027cd36..641dd35104 100644 --- a/src/declarative/items/qsglistview.cpp +++ b/src/declarative/items/qsglistview.cpp @@ -1751,6 +1751,16 @@ void QSGListView::itemsRemoved(int modelIndex, int count) if (firstVisible && d->visibleItems.first() != firstVisible) static_cast<FxListItemSG*>(d->visibleItems.first())->setPosition(d->visibleItems.first()->position() + preRemovedSize); + // update visibleIndex + bool haveVisibleIndex = false; + for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { + if ((*it)->index != -1) { + d->visibleIndex = (*it)->index; + haveVisibleIndex = true; + break; + } + } + // fix current if (d->currentIndex >= modelIndex + count) { d->currentIndex -= count; @@ -1771,16 +1781,6 @@ void QSGListView::itemsRemoved(int modelIndex, int count) emit currentIndexChanged(); } - // update visibleIndex - bool haveVisibleIndex = false; - for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { - if ((*it)->index != -1) { - d->visibleIndex = (*it)->index; - haveVisibleIndex = true; - break; - } - } - if (!haveVisibleIndex) { d->timeline.clear(); if (removedVisible && d->itemCount == 0) { diff --git a/src/qtquick1/graphicsitems/qdeclarativegridview.cpp b/src/qtquick1/graphicsitems/qdeclarativegridview.cpp index f81256c2ba..63b907b022 100644 --- a/src/qtquick1/graphicsitems/qdeclarativegridview.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativegridview.cpp @@ -2919,6 +2919,15 @@ void QDeclarative1GridView::itemsRemoved(int modelIndex, int count) } } + // update visibleIndex + d->visibleIndex = 0; + for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { + if ((*it)->index != -1) { + d->visibleIndex = (*it)->index; + break; + } + } + // fix current if (d->currentIndex >= modelIndex + count) { d->currentIndex -= count; @@ -2936,15 +2945,6 @@ void QDeclarative1GridView::itemsRemoved(int modelIndex, int count) emit currentIndexChanged(); } - // update visibleIndex - d->visibleIndex = 0; - for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { - if ((*it)->index != -1) { - d->visibleIndex = (*it)->index; - break; - } - } - if (removedVisible && d->visibleItems.isEmpty()) { d->timeline.clear(); if (d->itemCount == 0) { diff --git a/src/qtquick1/graphicsitems/qdeclarativelistview.cpp b/src/qtquick1/graphicsitems/qdeclarativelistview.cpp index 4c01514801..c58543c735 100644 --- a/src/qtquick1/graphicsitems/qdeclarativelistview.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativelistview.cpp @@ -3383,6 +3383,16 @@ void QDeclarative1ListView::itemsRemoved(int modelIndex, int count) if (firstVisible && d->visibleItems.first() != firstVisible) d->visibleItems.first()->setPosition(d->visibleItems.first()->position() + preRemovedSize); + // update visibleIndex + bool haveVisibleIndex = false; + for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { + if ((*it)->index != -1) { + d->visibleIndex = (*it)->index; + haveVisibleIndex = true; + break; + } + } + // fix current if (d->currentIndex >= modelIndex + count) { d->currentIndex -= count; @@ -3401,16 +3411,6 @@ void QDeclarative1ListView::itemsRemoved(int modelIndex, int count) emit currentIndexChanged(); } - // update visibleIndex - bool haveVisibleIndex = false; - for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { - if ((*it)->index != -1) { - d->visibleIndex = (*it)->index; - haveVisibleIndex = true; - break; - } - } - if (!haveVisibleIndex) { d->timeline.clear(); if (removedVisible && d->itemCount == 0) { |