summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-11-27 03:47:03 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-11-27 03:47:03 (GMT)
commite745245bd86333b0512f50728b80c4610a081a44 (patch)
tree05c36bbe5dd44199e7e1efa915946c6f42699991
parent03e80ad9057ecc12a3e61e8a968e390023e5561d (diff)
downloadQt-e745245bd86333b0512f50728b80c4610a081a44.zip
Qt-e745245bd86333b0512f50728b80c4610a081a44.tar.gz
Qt-e745245bd86333b0512f50728b80c4610a081a44.tar.bz2
Some fixes for positionViewAtIndex().
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index 0224465..7d0b99a 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -1716,15 +1716,14 @@ void QmlGraphicsListView::decrementCurrentIndex()
void QmlGraphicsListView::positionViewAtIndex(int index)
{
Q_D(QmlGraphicsListView);
- if (index < 0 || index >= d->model->count())
+ if (!d->isValid() || index < 0 || index >= d->model->count())
return;
+ qreal maxExtent = d->orient == QmlGraphicsListView::Vertical ? -maxYExtent() : -maxXExtent();
FxListItem *item = d->visibleItem(index);
if (item) {
// Already created - just move to top of view
- int pos = item->position();
- if (item->position() > -maxYExtent())
- pos = -maxYExtent();
+ int pos = qMin(item->position(), maxExtent);
d->setPosition(pos);
} else {
int pos = d->positionAt(index);
@@ -1734,8 +1733,9 @@ void QmlGraphicsListView::positionViewAtIndex(int index)
d->visiblePos = pos;
d->visibleIndex = index;
d->setPosition(pos);
- if (d->position() > -maxYExtent())
- d->setPosition(-maxYExtent());
+ // setPosition() will cause refill. Adjust if we have moved beyond range.
+ if (d->position() > maxExtent)
+ d->setPosition(maxExtent);
// now release the reference to all the old visible items.
for (int i = 0; i < oldVisible.count(); ++i)
d->releaseItem(oldVisible.at(i));