diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-11-18 05:53:08 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-11-18 05:53:08 (GMT) |
commit | f93cc8dda10c7f6a7a408d818ecafda23150e20c (patch) | |
tree | b4adb77d857f8c4f61ae86ff55599b737f68a526 /src/declarative/graphicsitems | |
parent | eaa5d6d945b5bcab2cbdce01a0780ccdadbd2719 (diff) | |
download | Qt-f93cc8dda10c7f6a7a408d818ecafda23150e20c.zip Qt-f93cc8dda10c7f6a7a408d818ecafda23150e20c.tar.gz Qt-f93cc8dda10c7f6a7a408d818ecafda23150e20c.tar.bz2 |
ListView tests and fixes.
Diffstat (limited to 'src/declarative/graphicsitems')
3 files changed, 13 insertions, 5 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp index 5ce2836..473f9e5 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp @@ -950,7 +950,6 @@ void QmlGraphicsGridView::setHighlight(QmlComponent *highlight) { Q_D(QmlGraphicsGridView); if (highlight != d->highlightComponent) { - delete d->highlightComponent; d->highlightComponent = highlight; d->updateCurrent(d->currentIndex); } diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index a166df2..c6291f2 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -503,7 +503,7 @@ void QmlGraphicsListViewPrivate::refill(qreal from, qreal to) return; from -= buffer; to += buffer; - int modelIndex = 0; + int modelIndex = visibleIndex; qreal itemEnd = visiblePos-1; if (!visibleItems.isEmpty()) { visiblePos = visibleItems.first()->position(); @@ -1169,6 +1169,9 @@ void QmlGraphicsListView::setDelegate(QmlComponent *delegate) if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model)) { dataModel->setDelegate(delegate); if (isComponentComplete()) { + for (int i = 0; i < d->visibleItems.count(); ++i) + d->releaseItem(d->visibleItems.at(i)); + d->visibleItems.clear(); refill(); d->moveReason = QmlGraphicsListViewPrivate::SetIndex; d->updateCurrent(d->currentIndex); @@ -1268,9 +1271,10 @@ void QmlGraphicsListView::setHighlight(QmlComponent *highlight) { Q_D(QmlGraphicsListView); if (highlight != d->highlightComponent) { - delete d->highlightComponent; d->highlightComponent = highlight; - d->updateCurrent(d->currentIndex); + d->createHighlight(); + if (d->currentItem) + d->updateHighlight(); } } diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp index cf5fc5e..e8ee196 100644 --- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp @@ -692,11 +692,16 @@ QmlComponent *QmlGraphicsVisualDataModel::delegate() const void QmlGraphicsVisualDataModel::setDelegate(QmlComponent *delegate) { Q_D(QmlGraphicsVisualDataModel); + bool wasValid = d->m_delegate != 0; d->m_delegate = delegate; - if (d->modelCount()) { + if (!wasValid && d->modelCount() && d->m_delegate) { emit itemsInserted(0, d->modelCount()); emit countChanged(); } + if (wasValid && !d->m_delegate && d->modelCount()) { + emit itemsRemoved(0, d->modelCount()); + emit countChanged(); + } } QString QmlGraphicsVisualDataModel::part() const |