summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 2402648..6bad4da 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -53,6 +53,7 @@
#include <qdeclarativedeclarativedata_p.h>
#include <qdeclarativepropertycache_p.h>
#include <qdeclarativeguard_p.h>
+#include <qdeclarativeglobal_p.h>
#include <qlistmodelinterface_p.h>
#include <qhash.h>
@@ -80,6 +81,14 @@ public:
static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->emitChildrenChanged();
}
+ static int children_count(QDeclarativeListProperty<QDeclarativeItem> *prop) {
+ return static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->children.count();
+ }
+
+ static QDeclarativeItem *children_at(QDeclarativeListProperty<QDeclarativeItem> *prop, int index) {
+ return static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->children.at(index);
+ }
+
void itemAppended() {
Q_Q(QDeclarativeVisualItemModel);
QDeclarativeVisualItemModelAttached *attached = QDeclarativeVisualItemModelAttached::properties(children.last());
@@ -135,7 +144,8 @@ QDeclarativeVisualItemModel::QDeclarativeVisualItemModel()
QDeclarativeListProperty<QDeclarativeItem> QDeclarativeVisualItemModel::children()
{
Q_D(QDeclarativeVisualItemModel);
- return QDeclarativeListProperty<QDeclarativeItem>(this, d, QDeclarativeVisualItemModelPrivate::children_append);
+ return QDeclarativeListProperty<QDeclarativeItem>(this, d, d->children_append,
+ d->children_count, d->children_at);
}
/*!
@@ -473,7 +483,7 @@ QVariant QDeclarativeVisualDataModelDataMetaObject::initialValue(int propId)
QDeclarativeVisualDataModelData::QDeclarativeVisualDataModelData(int index,
QDeclarativeVisualDataModel *model)
-: m_index(index), m_model(model),
+: m_index(index), m_model(model),
m_meta(new QDeclarativeVisualDataModelDataMetaObject(this, QDeclarativeVisualDataModelPrivate::get(model)->m_delegateDataType))
{
QDeclarativeVisualDataModelPrivate *modelPriv = QDeclarativeVisualDataModelPrivate::get(model);
@@ -540,7 +550,7 @@ QVariant QDeclarativeVisualDataModelPartsMetaObject::initialValue(int id)
}
QDeclarativeVisualDataModelParts::QDeclarativeVisualDataModelParts(QDeclarativeVisualDataModel *parent)
-: QObject(parent), model(parent)
+: QObject(parent), model(parent)
{
new QDeclarativeVisualDataModelPartsMetaObject(this);
}
@@ -830,7 +840,7 @@ void QDeclarativeVisualDataModel::setDelegate(QDeclarativeComponent *delegate)
Rectangle {
height: 25; width: 100
Text { text: path }
- MouseRegion {
+ MouseArea {
anchors.fill: parent;
onClicked: myModel.setRoot(path)
}
@@ -917,7 +927,9 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q
if (inPackage) {
emit destroyingPackage(qobject_cast<QDeclarativePackage*>(obj));
} else {
- item->setVisible(false);
+ if (item->hasFocus())
+ item->clearFocus();
+ item->setOpacity(0.0);
static_cast<QGraphicsItem*>(item)->setParentItem(0);
}
stat |= Destroyed;
@@ -959,7 +971,7 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q
QObject *QDeclarativeVisualDataModel::parts()
{
Q_D(QDeclarativeVisualDataModel);
- if (!d->m_parts)
+ if (!d->m_parts)
d->m_parts = new QDeclarativeVisualDataModelParts(this);
return d->m_parts;
}
@@ -984,8 +996,8 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray
if (complete)
d->m_delegate->completeCreate();
if (nobj) {
- ctxt->setParent(nobj);
- data->setParent(nobj);
+ QDeclarative_setParent_noEvent(ctxt, nobj);
+ QDeclarative_setParent_noEvent(data, nobj);
d->m_cache.insertItem(index, nobj);
if (QDeclarativePackage *package = qobject_cast<QDeclarativePackage *>(nobj))
emit createdPackage(index, package);
@@ -1268,7 +1280,6 @@ void QDeclarativeVisualDataModel::_q_dataChanged(const QModelIndex &begin, const
void QDeclarativeVisualDataModel::_q_modelReset()
{
- Q_D(QDeclarativeVisualDataModel);
emit modelReset();
}