summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmldeclarativedata_p.h
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-06-11 08:47:07 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-06-11 08:47:07 (GMT)
commit7e541e9e4832a26339a44ee55d325ba089717e17 (patch)
tree8ac3583740a6df8642b42d9759f7782fbdd9817a /src/declarative/qml/qmldeclarativedata_p.h
parentaef2140573c5b68062db2f1a2cf968a1637344ae (diff)
downloadQt-7e541e9e4832a26339a44ee55d325ba089717e17.zip
Qt-7e541e9e4832a26339a44ee55d325ba089717e17.tar.gz
Qt-7e541e9e4832a26339a44ee55d325ba089717e17.tar.bz2
Skeleton for property deferring
Diffstat (limited to 'src/declarative/qml/qmldeclarativedata_p.h')
-rw-r--r--src/declarative/qml/qmldeclarativedata_p.h94
1 files changed, 91 insertions, 3 deletions
diff --git a/src/declarative/qml/qmldeclarativedata_p.h b/src/declarative/qml/qmldeclarativedata_p.h
index fb7a015..b8d3cf4 100644
--- a/src/declarative/qml/qmldeclarativedata_p.h
+++ b/src/declarative/qml/qmldeclarativedata_p.h
@@ -52,20 +52,108 @@ public:
QmlSimpleDeclarativeData() : flags(0), context(0) {}
virtual void destroyed(QObject *);
- enum Flag { Extended = 0x00000001 };
+ enum Flag { Instance = 0x00000001, Extended = 0x00000002 };
quint32 flags;
QmlContext *context;
+
+ static inline QmlSimpleDeclarativeData *get(QObject *object,
+ bool create = false);
};
-class QmlExtendedDeclarativeData : public QmlSimpleDeclarativeData
+class QmlCompiledComponent;
+class QmlInstanceDeclarativeData : public QmlSimpleDeclarativeData
{
public:
- QmlExtendedDeclarativeData() { flags = Extended; }
+ QmlInstanceDeclarativeData() { flags |= Instance; }
virtual void destroyed(QObject *);
+
+ QmlCompiledComponent *deferredComponent;
+ unsigned int deferredIdx;
+
+ static inline QmlInstanceDeclarativeData *get(QObject *object,
+ bool create = false);
+};
+
+class QmlExtendedDeclarativeData : public QmlInstanceDeclarativeData
+{
+public:
+ QmlExtendedDeclarativeData() { flags |= Extended; }
+
QHash<int, QObject *> attachedProperties;
+
+ static inline QmlExtendedDeclarativeData *get(QObject *object,
+ bool create = false);
};
+QmlSimpleDeclarativeData *
+QmlSimpleDeclarativeData::get(QObject *object, bool create)
+{
+ QObjectPrivate *priv = QObjectPrivate::get(object);
+
+ if (create && !priv->declarativeData)
+ priv->declarativeData = new QmlInstanceDeclarativeData;
+
+ return static_cast<QmlSimpleDeclarativeData *>(priv->declarativeData);
+}
+
+QmlInstanceDeclarativeData *
+QmlInstanceDeclarativeData::get(QObject *object, bool create)
+{
+ QObjectPrivate *priv = QObjectPrivate::get(object);
+
+ QmlSimpleDeclarativeData *simple =
+ static_cast<QmlSimpleDeclarativeData *>(priv->declarativeData);
+
+ if (simple && (simple->flags & Instance)) {
+ return static_cast<QmlInstanceDeclarativeData *>(simple);
+ } else if (create && simple) {
+ QmlInstanceDeclarativeData *rv = new QmlInstanceDeclarativeData;
+ rv->context = simple->context;
+ simple->destroyed(object);
+ priv->declarativeData = rv;
+ return rv;
+ } else if (create) {
+ QmlInstanceDeclarativeData *rv = new QmlInstanceDeclarativeData;
+ priv->declarativeData = rv;
+ return rv;
+ }
+ return 0;
+}
+
+QmlExtendedDeclarativeData *
+QmlExtendedDeclarativeData::get(QObject *object, bool create)
+{
+ QObjectPrivate *priv = QObjectPrivate::get(object);
+
+ QmlSimpleDeclarativeData *simple =
+ static_cast<QmlSimpleDeclarativeData *>(priv->declarativeData);
+
+ if (simple && (simple->flags & Extended)) {
+ return static_cast<QmlExtendedDeclarativeData *>(simple);
+ } else if (create && simple) {
+ QmlExtendedDeclarativeData *rv = new QmlExtendedDeclarativeData;
+ rv->context = simple->context;
+
+ if (simple->flags & Instance) {
+ QmlInstanceDeclarativeData *instance =
+ static_cast<QmlInstanceDeclarativeData *>(priv->declarativeData);
+ rv->deferredComponent = instance->deferredComponent;
+ rv->deferredIdx = instance->deferredIdx;
+ delete simple;
+ } else {
+ simple->destroyed(object);
+ }
+ priv->declarativeData = rv;
+ return rv;
+ } else if (create) {
+ QmlExtendedDeclarativeData *rv = new QmlExtendedDeclarativeData;
+ priv->declarativeData = rv;
+ return rv;
+ }
+ return 0;
+}
+
QT_END_NAMESPACE
#endif // QMLDECLARATIVEDATA_P_H