summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-04-13 05:31:31 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-04-13 05:31:31 (GMT)
commit61c13dad7bf04642033f01cad81ea422ab89b122 (patch)
treea95f37e2ee15cff1691292ad4ad5103b3bc391d5 /src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
parente19f299dfc77a9efc223203655df95175355d527 (diff)
downloadQt-61c13dad7bf04642033f01cad81ea422ab89b122.zip
Qt-61c13dad7bf04642033f01cad81ea422ab89b122.tar.gz
Qt-61c13dad7bf04642033f01cad81ea422ab89b122.tar.bz2
Improve efficiency of model dataChanged.
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 15348ed..dc325ce 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -1127,20 +1127,21 @@ void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count,
const QList<int> &roles)
{
Q_D(QDeclarativeVisualDataModel);
- // XXX - highly inefficient
- for (int ii = index; ii < index + count; ++ii) {
-
- if (QObject *item = d->m_cache.item(ii)) {
- QDeclarativeVisualDataModelData *data = d->data(item);
+ for (QHash<int,QDeclarativeVisualDataModelPrivate::ObjectRef>::ConstIterator iter = d->m_cache.begin();
+ iter != d->m_cache.end(); ++iter) {
+ const int idx = iter.key();
+ if (idx >= index && idx < index+count) {
+ QDeclarativeVisualDataModelPrivate::ObjectRef objRef = *iter;
+ QDeclarativeVisualDataModelData *data = d->data(objRef.obj);
for (int roleIdx = 0; roleIdx < roles.count(); ++roleIdx) {
int role = roles.at(roleIdx);
int propId = data->propForRole(role);
if (propId != -1) {
if (d->m_listModelInterface) {
- data->setValue(propId, d->m_listModelInterface->data(ii, QList<int>() << role).value(role));
+ data->setValue(propId, d->m_listModelInterface->data(idx, QList<int>() << role).value(role));
} else if (d->m_abstractItemModel) {
- QModelIndex index = d->m_abstractItemModel->index(ii, 0, d->m_root);
+ QModelIndex index = d->m_abstractItemModel->index(idx, 0, d->m_root);
data->setValue(propId, d->m_abstractItemModel->data(index, role));
}
}