From f7c07892e927a6420bb64a7011312f0a4a5a1fc9 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 16 Aug 2010 11:17:56 +1000 Subject: emit countChanged where appropriate in Repeater Task-number: QTBUG-12905 Reviewed-by: Bea Lam --- src/declarative/graphicsitems/qdeclarativerepeater.cpp | 5 ++++- .../declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp index 68e7e9a..b4b6c02 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp @@ -245,8 +245,8 @@ void QDeclarativeRepeater::setModel(const QVariant &model) connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); */ regenerate(); - emit countChanged(); } + emit countChanged(); } /*! @@ -377,6 +377,7 @@ void QDeclarativeRepeater::itemsInserted(int index, int count) d->deletables.insert(modelIndex, item); } } + emit countChanged(); } void QDeclarativeRepeater::itemsRemoved(int index, int count) @@ -391,6 +392,7 @@ void QDeclarativeRepeater::itemsRemoved(int index, int count) else break; } + emit countChanged(); } void QDeclarativeRepeater::itemsMoved(int from, int to, int count) @@ -420,6 +422,7 @@ void QDeclarativeRepeater::modelReset() if (!isComponentComplete()) return; regenerate(); + emit countChanged(); } QT_END_NAMESPACE diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp index 623b3d7..360d90f 100644 --- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp +++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp @@ -309,11 +309,14 @@ void tst_QDeclarativeRepeater::dataModel() QCOMPARE(container->childItems().count(), 4); + QSignalSpy repeaterSpy(repeater, SIGNAL(countChanged())); testModel.addItem("four", "4"); QCOMPARE(container->childItems().count(), 5); + QCOMPARE(repeaterSpy.count(),1); testModel.removeItem(2); QCOMPARE(container->childItems().count(), 4); + QCOMPARE(repeaterSpy.count(),2); // Check that model changes are propagated QDeclarativeText *text = findItem(canvas->rootObject(), "myName", 1); -- cgit v0.12