summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmldeclarativedata_p.h
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-08-10 03:44:48 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-08-10 03:44:48 (GMT)
commit12ffa33ddc725cd94662a383af6e1793049c807c (patch)
tree8190ce28b9cc6bd23736f718ded3b59d32be80d0 /src/declarative/qml/qmldeclarativedata_p.h
parent3ee9db1d892927522832b6bc8e1d806e27015bc4 (diff)
downloadQt-12ffa33ddc725cd94662a383af6e1793049c807c.zip
Qt-12ffa33ddc725cd94662a383af6e1793049c807c.tar.gz
Qt-12ffa33ddc725cd94662a383af6e1793049c807c.tar.bz2
Simplify QmlDeclarativeData to a single class
Diffstat (limited to 'src/declarative/qml/qmldeclarativedata_p.h')
-rw-r--r--src/declarative/qml/qmldeclarativedata_p.h113
1 files changed, 18 insertions, 95 deletions
diff --git a/src/declarative/qml/qmldeclarativedata_p.h b/src/declarative/qml/qmldeclarativedata_p.h
index b473e77..8d30bcc 100644
--- a/src/declarative/qml/qmldeclarativedata_p.h
+++ b/src/declarative/qml/qmldeclarativedata_p.h
@@ -57,113 +57,36 @@
QT_BEGIN_NAMESPACE
-class QmlSimpleDeclarativeData : public QDeclarativeData
-{
-public:
- QmlSimpleDeclarativeData() : flags(0), context(0) {}
-
- virtual void destroyed(QObject *);
- enum Flag { Instance = 0x00000001, Extended = 0x00000002 };
- quint32 flags;
- QmlContext *context;
-
- static inline QmlSimpleDeclarativeData *get(QObject *object,
- bool create = false);
-};
-
class QmlCompiledData;
-class QmlInstanceDeclarativeData : public QmlSimpleDeclarativeData
+class QmlBinding;
+class QmlDeclarativeData : public QDeclarativeData
{
public:
- QmlInstanceDeclarativeData() : deferredComponent(0) { flags |= Instance; }
+ QmlDeclarativeData(QmlContext *context = 0);
virtual void destroyed(QObject *);
- QmlCompiledData *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);
+ QmlContext *context;
+ QmlBinding *bindings;
- QmlSimpleDeclarativeData *simple =
- static_cast<QmlSimpleDeclarativeData *>(priv->declarativeData);
+ QmlCompiledData *deferredComponent; // Can't this be found from the context?
+ unsigned int deferredIdx;
- if (simple && (simple->flags & Extended)) {
- return static_cast<QmlExtendedDeclarativeData *>(simple);
- } else if (create && simple) {
- QmlExtendedDeclarativeData *rv = new QmlExtendedDeclarativeData;
- rv->context = simple->context;
+ QHash<int, QObject *> *attachedProperties;
- if (simple->flags & Instance) {
- QmlInstanceDeclarativeData *instance =
- static_cast<QmlInstanceDeclarativeData *>(priv->declarativeData);
- rv->deferredComponent = instance->deferredComponent;
- rv->deferredIdx = instance->deferredIdx;
- delete simple;
+ static QmlDeclarativeData *get(const QObject *object, bool create = false) {
+ QObjectPrivate *priv =
+ QObjectPrivate::get(const_cast<QObject *>(object));
+ if (priv && priv->declarativeData) {
+ return static_cast<QmlDeclarativeData *>(priv->declarativeData);
+ } else if (create && priv) {
+ priv->declarativeData = new QmlDeclarativeData;
+ return static_cast<QmlDeclarativeData *>(priv->declarativeData);
} else {
- simple->destroyed(object);
+ return 0;
}
- priv->declarativeData = rv;
- return rv;
- } else if (create) {
- QmlExtendedDeclarativeData *rv = new QmlExtendedDeclarativeData;
- priv->declarativeData = rv;
- return rv;
}
- return 0;
-}
+};
QT_END_NAMESPACE