aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-05-05 14:18:28 +1000
committerOlivier Goffart <olivier.goffart@nokia.com>2011-05-11 17:00:06 +0200
commitbc83e44dc31cf4688d9b10d0540e61f5d0e37cdc (patch)
tree29663e6110763c7d1822ffde1ab21569711f951f /src/declarative/graphicsitems
parentdb49ce3f88653fffd6aa967a7acd73058ba1f214 (diff)
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 (cherry picked from commit 4fbcb6a531bf424a8dbbbd0ca2947d9e15118885)
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp3
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp3
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp3
3 files changed, 9 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index f30831d7d9..a3395a4fef 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 3190d7e209..27300c492b 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 aed849bd39..be2bd60fcd 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();
}
}