diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-05-05 04:38:55 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-05-05 04:38:55 (GMT) |
commit | ce9bc843443f2c61361afa75a62a7d39029557e6 (patch) | |
tree | a097566f26f14a1e0d2aa650cb803beb6ed1bddb /src/declarative | |
parent | 02df0ce446a89298109e1c7d0ef1e790d41d442f (diff) | |
download | Qt-ce9bc843443f2c61361afa75a62a7d39029557e6.zip Qt-ce9bc843443f2c61361afa75a62a7d39029557e6.tar.gz Qt-ce9bc843443f2c61361afa75a62a7d39029557e6.tar.bz2 |
QList<QObject*> models now update their properties when they change.
Task-number: QTBUG-10348
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/QmlChanges.txt | 4 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 7218f78..dfc4244 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -4,6 +4,10 @@ The changes below are pre Qt 4.7.0 RC Flickable: overShoot is replaced by boundsBehavior enumeration. Component: isReady, isLoading, isError and isNull properties removed, use status property instead +QList<QObject*> models no longer provide properties in model object. The +properties are now updated when the object changes. An object's property +"foo" may now be accessed as "foo", modelData.foo" or model.modelData.foo" + C++ API ------- diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 2addc77..f01d4c2 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -437,8 +437,7 @@ int QDeclarativeVisualDataModelDataMetaObject::createProperty(const char *name, if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) { if (model->m_listAccessor->type() == QDeclarativeListAccessor::ListProperty) { model->ensureRoles(); - QObject *object = model->m_listAccessor->at(data->m_index).value<QObject*>(); - if (object && (object->property(name).isValid() || qstrcmp(name,"modelData")==0)) + if (qstrcmp(name,"modelData") == 0) return QDeclarativeOpenMetaObject::createProperty(name, type); } } @@ -1029,6 +1028,11 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray if (!ccontext) ccontext = qmlContext(this); QDeclarativeContext *ctxt = new QDeclarativeContext(ccontext); QDeclarativeVisualDataModelData *data = new QDeclarativeVisualDataModelData(index, this); + if ((!d->m_listModelInterface || !d->m_abstractItemModel) && d->m_listAccessor + && d->m_listAccessor->type() == QDeclarativeListAccessor::ListProperty) { + ctxt->setContextObject(d->m_listAccessor->at(index).value<QObject*>()); + ctxt = new QDeclarativeContext(ctxt, ctxt); + } ctxt->setContextProperty(QLatin1String("model"), data); ctxt->setContextObject(data); d->m_completePending = false; |