diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-06-23 06:13:18 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-06-23 06:13:18 (GMT) |
commit | a60f8832425aafbe6c5e8be3c25fefc9f8f2f87b (patch) | |
tree | d3dc3a72de7b1d19671e2d006dc201842e7d85f0 /src/declarative | |
parent | 3e209785c3f027973089ccbebc6528501f416f2b (diff) | |
download | Qt-a60f8832425aafbe6c5e8be3c25fefc9f8f2f87b.zip Qt-a60f8832425aafbe6c5e8be3c25fefc9f8f2f87b.tar.gz Qt-a60f8832425aafbe6c5e8be3c25fefc9f8f2f87b.tar.bz2 |
Ensure the view is correctly positioned at component complete.
If a currentIndex has been specified, ensure the view starts at the
correct position immediately, rather than scrolling to it after
startup.
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativegridview.cpp | 9 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativelistview.cpp | 8 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 3792595..8e53237 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -2037,6 +2037,8 @@ void QDeclarativeGridView::positionViewAtIndex(int index, int mode) if (mode < Beginning || mode > Contain) return; + if (d->layoutScheduled) + d->layout(); qreal pos = d->position(); FxGridItem *item = d->visibleItem(index); if (!item) { @@ -2079,6 +2081,8 @@ void QDeclarativeGridView::positionViewAtIndex(int index, int mode) pos = qMin(pos, maxExtent); qreal minExtent = d->flow == QDeclarativeGridView::LeftToRight ? -minYExtent() : -minXExtent(); pos = qMax(pos, minExtent); + d->moveReason = QDeclarativeGridViewPrivate::Other; + cancelFlick(); d->setPosition(pos); } d->fixupPosition(); @@ -2113,10 +2117,15 @@ void QDeclarativeGridView::componentComplete() d->updateGrid(); if (d->isValid()) { refill(); + d->moveReason = QDeclarativeGridViewPrivate::SetIndex; if (d->currentIndex < 0) d->updateCurrent(0); else d->updateCurrent(d->currentIndex); + if (d->highlight) { + d->highlight->setPosition(d->currentItem->colPos(), d->currentItem->rowPos()); + d->updateTrackedItem(); + } d->fixupPosition(); } } diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 06a3239..35e6bab 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -2448,6 +2448,8 @@ void QDeclarativeListView::positionViewAtIndex(int index, int mode) if (mode < Beginning || mode > Contain) return; + if (d->layoutScheduled) + d->layout(); qreal pos = d->position(); FxListItem *item = d->visibleItem(index); if (!item) { @@ -2491,6 +2493,8 @@ void QDeclarativeListView::positionViewAtIndex(int index, int mode) pos = qMin(pos, maxExtent); qreal minExtent = d->orient == QDeclarativeListView::Vertical ? -minYExtent() : -minXExtent(); pos = qMax(pos, minExtent); + d->moveReason = QDeclarativeListViewPrivate::Other; + cancelFlick(); d->setPosition(pos); } d->fixupPosition(); @@ -2529,6 +2533,10 @@ void QDeclarativeListView::componentComplete() d->updateCurrent(0); else d->updateCurrent(d->currentIndex); + if (d->highlight) { + d->highlight->setPosition(d->currentItem->position()); + d->updateTrackedItem(); + } d->fixupPosition(); } } |