28 #include <QQmlListProperty>
31 namespace QtProtobuf {
34 static void qmllistpropertyAppend(QQmlListProperty<T> *p, T *v) {
35 QQmlEngine::setObjectOwnership(v, QQmlEngine::CppOwnership);
36 reinterpret_cast<QList<QSharedPointer<T>
> *>(p->data)->append(QSharedPointer<T>(v));
41 static int qmllistpropertyCount(QQmlListProperty<T> *p) {
42 return reinterpret_cast<QList<QSharedPointer<T>
> *>(p->data)->count();
47 static T *qmllistpropertyAt(QQmlListProperty<T> *p,
int index) {
48 return reinterpret_cast<QList<QSharedPointer<T>
> *>(p->data)->at(index).data();
53 static void qmllistpropertyReset(QQmlListProperty<T> *p) {
54 reinterpret_cast<QList<QSharedPointer<T>
> *>(p->data)->clear();
59 static QQmlListProperty<T> constructQmlListProperty(QObject *p, QList<QSharedPointer<T>> *data)
61 return QQmlListProperty<T>(p, data, qmllistpropertyAppend<T>, qmllistpropertyCount<T>,
62 qmllistpropertyAt<T>, qmllistpropertyReset<T>);