diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-08 00:21:46 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-08 00:23:37 (GMT) |
commit | 9d9161446bfad883c298d54a122e822c5e273a9c (patch) | |
tree | 931a81ca20b9c2bce70a232e9f2888602511b7a4 /src/declarative/util | |
parent | 2c40b2faac1d9bd941310c0c0e1e0d0fa0033ab5 (diff) | |
download | Qt-9d9161446bfad883c298d54a122e822c5e273a9c.zip Qt-9d9161446bfad883c298d54a122e822c5e273a9c.tar.gz Qt-9d9161446bfad883c298d54a122e822c5e273a9c.tar.bz2 |
Support QList<QObject*> properties
We already supported returning QList<QObject*> from methods, but there
wasn't really much that could be done with the return value. This closes
the loop on QList<QObject*> support by allowing them to be properties,
and used as models.
Diffstat (limited to 'src/declarative/util')
-rw-r--r-- | src/declarative/util/qdeclarativelistaccessor.cpp | 6 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativelistaccessor_p.h | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/declarative/util/qdeclarativelistaccessor.cpp b/src/declarative/util/qdeclarativelistaccessor.cpp index 4ac587f..f91b2fb 100644 --- a/src/declarative/util/qdeclarativelistaccessor.cpp +++ b/src/declarative/util/qdeclarativelistaccessor.cpp @@ -84,6 +84,8 @@ void QDeclarativeListAccessor::setList(const QVariant &v, QDeclarativeEngine *en QObject *data = enginePrivate?enginePrivate->toQObject(v):QDeclarativeMetaType::toQObject(v); d = QVariant::fromValue(data); m_type = Instance; + } else if (d.userType() == qMetaTypeId<QList<QObject *> >()) { + m_type = ObjectList; } else if (d.userType() == qMetaTypeId<QDeclarativeListReference>()) { m_type = ListProperty; } else { @@ -98,6 +100,8 @@ int QDeclarativeListAccessor::count() const return qvariant_cast<QStringList>(d).count(); case VariantList: return qvariant_cast<QVariantList>(d).count(); + case ObjectList: + return qvariant_cast<QList<QObject*> >(d).count(); case ListProperty: return ((QDeclarativeListReference *)d.constData())->count(); case Instance: @@ -118,6 +122,8 @@ QVariant QDeclarativeListAccessor::at(int idx) const return QVariant::fromValue(qvariant_cast<QStringList>(d).at(idx)); case VariantList: return qvariant_cast<QVariantList>(d).at(idx); + case ObjectList: + return QVariant::fromValue(qvariant_cast<QList<QObject*> >(d).at(idx)); case ListProperty: return QVariant::fromValue(((QDeclarativeListReference *)d.constData())->at(idx)); case Instance: diff --git a/src/declarative/util/qdeclarativelistaccessor_p.h b/src/declarative/util/qdeclarativelistaccessor_p.h index d8bb8af..10d944a 100644 --- a/src/declarative/util/qdeclarativelistaccessor_p.h +++ b/src/declarative/util/qdeclarativelistaccessor_p.h @@ -65,7 +65,7 @@ public: int count() const; QVariant at(int) const; - enum Type { Invalid, StringList, VariantList, ListProperty, Instance, Integer }; + enum Type { Invalid, StringList, VariantList, ObjectList, ListProperty, Instance, Integer }; Type type() const { return m_type; } private: |