#ifndef QQMLLISTPROPERTYHELPER #define QQMLLISTPROPERTYHELPER #include #include #define QML_LIST_PROPERTY(CLASS, NAME, TYPE) \ public: \ static int NAME##_count (QQmlListProperty * prop) { \ CLASS * instance = qobject_cast (prop->object); \ return (instance != NULL ? instance->m_##NAME.count () : 0); \ } \ static void NAME##_clear (QQmlListProperty * prop) { \ CLASS * instance = qobject_cast (prop->object); \ if (instance != NULL) { \ instance->m_##NAME.clear (); \ } \ } \ static void NAME##_append (QQmlListProperty * prop, TYPE * obj) { \ CLASS * instance = qobject_cast (prop->object); \ if (instance != NULL && obj != NULL) { \ instance->m_##NAME.append (obj); \ } \ } \ static TYPE * NAME##_at (QQmlListProperty * prop, int idx) { \ CLASS * instance = qobject_cast (prop->object); \ return (instance != NULL ? instance->m_##NAME.at (idx) : NULL); \ } \ QList get_##NAME##s (void) const { \ return m_##NAME; \ } \ private: \ QList m_##NAME; #endif // QQMLLISTPROPERTYHELPER