diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-12-13 07:33:13 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-12-13 07:36:46 (GMT) |
commit | 95ddfa13737164c93c58ce3694ce59ec68a016d9 (patch) | |
tree | 2b0b2bca8394e72771d4334378a03c64b3d57a1e /src/declarative | |
parent | 2e2f26072647b08292955ebad631c34d58c828f9 (diff) | |
download | Qt-95ddfa13737164c93c58ce3694ce59ec68a016d9.zip Qt-95ddfa13737164c93c58ce3694ce59ec68a016d9.tar.gz Qt-95ddfa13737164c93c58ce3694ce59ec68a016d9.tar.bz2 |
Ensure ListView contentHeight is set to a valid size.
If the view height is 0 no items will be created so the contentHeight
can not be estimated. The currentItem is usually created,
so it is possible to use that to estimate.
Task-number: QTBUG-16037
Reviewed-by: Bea Lam
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativelistview.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index d008f91..2a7f508 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -265,6 +265,8 @@ public: } } pos = (*(--visibleItems.constEnd()))->endPosition() + invisibleCount * (averageSize + spacing); + } else if (model && model->count()) { + pos = model->count() * averageSize + (model->count()-1) * spacing; } return pos; } @@ -1050,6 +1052,8 @@ void QDeclarativeListViewPrivate::updateCurrent(int modelIndex) // This is slightly sub-optimal, but section heading caching minimizes the impact. if (currentItem->section) currentItem->section->setVisible(false); + if (visibleItems.isEmpty()) + averageSize = currentItem->size(); } updateHighlight(); emit q->currentIndexChanged(); @@ -1576,6 +1580,7 @@ void QDeclarativeListView::setModel(const QVariant &model) d->updateTrackedItem(); } } + d->updateViewport(); } connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); @@ -1647,6 +1652,7 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate) d->highlight->setPosition(d->currentItem->position()); d->updateTrackedItem(); } + d->updateViewport(); } } emit delegateChanged(); |