diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-10-26 03:33:29 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-10-26 03:35:14 (GMT) |
commit | c5315a322a65971d636bd73e2444cdd8565e00f4 (patch) | |
tree | 5bc876c16fdccae4ef140f09af50bfbc1b282d01 | |
parent | 24498457049f0504d0b09935dea6ca6a5634bb2d (diff) | |
download | Qt-c5315a322a65971d636bd73e2444cdd8565e00f4.zip Qt-c5315a322a65971d636bd73e2444cdd8565e00f4.tar.gz Qt-c5315a322a65971d636bd73e2444cdd8565e00f4.tar.bz2 |
Fix accessing QmlList data as a model.
-rw-r--r-- | src/declarative/fx/qfxvisualitemmodel.cpp | 15 | ||||
-rw-r--r-- | src/declarative/util/qmllistaccessor.cpp | 2 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp index a078da6..e1ac246 100644 --- a/src/declarative/fx/qfxvisualitemmodel.cpp +++ b/src/declarative/fx/qfxvisualitemmodel.cpp @@ -102,7 +102,7 @@ QHash<QObject*, QFxVisualItemModelAttached*> QFxVisualItemModelAttached::attache class QFxVisualItemModelPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QFxVisualItemModel); + Q_DECLARE_PUBLIC(QFxVisualItemModel) public: QFxVisualItemModelPrivate() : QObjectPrivate(), children(this) {} @@ -143,7 +143,7 @@ public: \code Item { VisualItemModel { - id: ItemModel + id: itemModel Rectangle { height: 30; width: 80; color: "red" } Rectangle { height: 30; width: 80; color: "green" } Rectangle { height: 30; width: 80; color: "blue" } @@ -151,7 +151,7 @@ public: ListView { anchors.fill: parent - model: ItemModel + model: itemModel } } \endcode @@ -416,8 +416,13 @@ int QFxVisualDataModelDataMetaObject::createProperty(const char *name, const cha if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) { model->ensureRoles(); - if (model->m_roleNames.contains(QString::fromUtf8(name))) + if (model->m_roleNames.contains(QString::fromUtf8(name))) { return QmlOpenMetaObject::createProperty(name, type); + } else if (model->m_listAccessor->type() == QmlListAccessor::QmlList) { + QObject *object = model->m_listAccessor->at(data->m_index).value<QObject*>(); + if (object && object->property(name).isValid()) + return QmlOpenMetaObject::createProperty(name, type); + } } else { model->ensureRoles(); QString sname = QString::fromUtf8(name); @@ -448,7 +453,7 @@ QFxVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuilder &pro return model->m_listAccessor->at(data->m_index); } else { // return any property of a single object instance. - QObject *object = model->m_listAccessor->at(0).value<QObject*>(); + QObject *object = model->m_listAccessor->at(data->m_index).value<QObject*>(); return object->property(prop.name()); } } else if (model->m_listModelInterface) { diff --git a/src/declarative/util/qmllistaccessor.cpp b/src/declarative/util/qmllistaccessor.cpp index 578646b..21007d6 100644 --- a/src/declarative/util/qmllistaccessor.cpp +++ b/src/declarative/util/qmllistaccessor.cpp @@ -136,7 +136,7 @@ QVariant QmlListAccessor::at(int idx) const QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData(); void *ptr[1]; li->at(idx, ptr); - return QmlMetaType::fromObject((QObject*)ptr[0], li->type()); //XXX only handles QObject-derived types + return QVariant::fromValue((QObject*)ptr[0]); } case QList: return QmlMetaType::listAt(d, idx); |