summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp37
1 files changed, 13 insertions, 24 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
index 4ced2c3..b96f399 100644
--- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
@@ -71,16 +71,14 @@ class QmlGraphicsVisualItemModelPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QmlGraphicsVisualItemModel)
public:
- QmlGraphicsVisualItemModelPrivate() : QObjectPrivate(), children(this) {}
+ QmlGraphicsVisualItemModelPrivate() : QObjectPrivate() {}
- struct ItemList : public QmlConcreteList<QmlGraphicsItem *>
- {
- ItemList(QmlGraphicsVisualItemModelPrivate *m) : QmlConcreteList<QmlGraphicsItem *>(), model(m) {}
-
- void append(QmlGraphicsItem *item);
-
- QmlGraphicsVisualItemModelPrivate *model;
- };
+ static void children_append(QmlListProperty<QmlGraphicsItem> *prop, QmlGraphicsItem *item) {
+ item->QObject::setParent(prop->object);
+ static_cast<QmlGraphicsVisualItemModelPrivate *>(prop->data)->children.append(item);
+ static_cast<QmlGraphicsVisualItemModelPrivate *>(prop->data)->itemAppended();
+ static_cast<QmlGraphicsVisualItemModelPrivate *>(prop->data)->emitChildrenChanged();
+ }
void itemAppended() {
Q_Q(QmlGraphicsVisualItemModel);
@@ -94,7 +92,8 @@ public:
Q_Q(QmlGraphicsVisualItemModel);
emit q->childrenChanged();
}
- ItemList children;
+
+ QList<QmlGraphicsItem *> children;
};
@@ -132,10 +131,10 @@ QmlGraphicsVisualItemModel::QmlGraphicsVisualItemModel()
{
}
-QmlList<QmlGraphicsItem *> *QmlGraphicsVisualItemModel::children()
+QmlListProperty<QmlGraphicsItem> QmlGraphicsVisualItemModel::children()
{
Q_D(QmlGraphicsVisualItemModel);
- return &(d->children);
+ return QmlListProperty<QmlGraphicsItem>(this, d, QmlGraphicsVisualItemModelPrivate::children_append);
}
/*!
@@ -200,15 +199,6 @@ int QmlGraphicsVisualItemModel::indexOf(QmlGraphicsItem *item, QObject *) const
return d->children.indexOf(item);
}
-void QmlGraphicsVisualItemModelPrivate::ItemList::append(QmlGraphicsItem *item)
-{
- QmlConcreteList<QmlGraphicsItem*>::append(item);
- item->QObject::setParent(model->q_ptr);
- model->itemAppended();
-
- model->emitChildrenChanged();
-}
-
QmlGraphicsVisualItemModelAttached *QmlGraphicsVisualItemModel::qmlAttachedProperties(QObject *obj)
{
return QmlGraphicsVisualItemModelAttached::properties(obj);
@@ -422,8 +412,7 @@ int QmlGraphicsVisualDataModelDataMetaObject::createProperty(const char *name, c
QmlGraphicsVisualDataModelPrivate *model = QmlGraphicsVisualDataModelPrivate::get(data->m_model);
if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) {
- if (model->m_listAccessor->type() == QmlListAccessor::QmlList
- || model->m_listAccessor->type() == QmlListAccessor::QListPtr) {
+ if (model->m_listAccessor->type() == QmlListAccessor::ListProperty) {
model->ensureRoles();
QObject *object = model->m_listAccessor->at(data->m_index).value<QObject*>();
if (object && object->property(name).isValid())
@@ -685,7 +674,7 @@ void QmlGraphicsVisualDataModel::setModel(const QVariant &model)
}
d->m_listAccessor = new QmlListAccessor;
d->m_listAccessor->setList(model, d->m_context?d->m_context->engine():qmlEngine(this));
- if (d->m_listAccessor->type() != QmlListAccessor::QmlList && d->m_listAccessor->type() != QmlListAccessor::QListPtr)
+ if (d->m_listAccessor->type() != QmlListAccessor::ListProperty)
d->m_metaDataCacheable = true;
if (d->m_delegate && d->modelCount()) {
emit itemsInserted(0, d->modelCount());