diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-05-05 04:18:28 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2011-05-05 04:18:28 (GMT) |
commit | 4fbcb6a531bf424a8dbbbd0ca2947d9e15118885 (patch) | |
tree | 73e33648cb54f5be25caa46af765080c18f95c36 /src/declarative | |
parent | 95aa4e4f9b82c3652ffc93310b190db869d491df (diff) | |
download | Qt-4fbcb6a531bf424a8dbbbd0ca2947d9e15118885.zip Qt-4fbcb6a531bf424a8dbbbd0ca2947d9e15118885.tar.gz Qt-4fbcb6a531bf424a8dbbbd0ca2947d9e15118885.tar.bz2 |
Views do not notify count changes properly
The views don't have a valid count until both a model and a delegate
are provided. But, countChanged() is not called when a delegate is
set after the model, so bindings to count were not evaluated. Also
test that count is updated for insertion/removal
Change-Id: Ic82039a624c02f0bdb2862ac7a6e215df75bb314
Task-number: QTBUG-19037
Reviewed-by: Bea Lam
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativegridview.cpp | 3 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativelistview.cpp | 3 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativepathview.cpp | 3 |
3 files changed, 9 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 05e64b9..460f2c3 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -1499,6 +1499,7 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate) d->ownModel = true; } if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) { + int oldCount = dataModel->count(); dataModel->setDelegate(delegate); if (isComponentComplete()) { for (int i = 0; i < d->visibleItems.count(); ++i) @@ -1516,6 +1517,8 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate) } d->moveReason = QDeclarativeGridViewPrivate::Other; } + if (oldCount != dataModel->count()) + emit countChanged(); emit delegateChanged(); } } diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 2e9822e..cb40384 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1813,6 +1813,7 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate) d->ownModel = true; } if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) { + int oldCount = dataModel->count(); dataModel->setDelegate(delegate); if (isComponentComplete()) { for (int i = 0; i < d->visibleItems.count(); ++i) @@ -1831,6 +1832,8 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate) } d->updateViewport(); } + if (oldCount != dataModel->count()) + emit countChanged(); } emit delegateChanged(); } diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index aed849b..be2bd60 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -1021,9 +1021,12 @@ void QDeclarativePathView::setDelegate(QDeclarativeComponent *delegate) d->ownModel = true; } if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) { + int oldCount = dataModel->count(); dataModel->setDelegate(delegate); d->modelCount = dataModel->count(); d->regenerate(); + if (oldCount != dataModel->count()) + emit countChanged(); emit delegateChanged(); } } |