summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp31
-rw-r--r--src/declarative/qml/qmlmetaproperty.h8
2 files changed, 37 insertions, 2 deletions
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index 1218b99..e7f7cfb 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -103,7 +103,18 @@ QmlMetaProperty::~QmlMetaProperty()
// ### not thread safe
static QHash<const QMetaObject *, QMetaPropertyEx> qmlCacheDefProp;
+
+/*!
+ Creates a QmlMetaProperty for the default property of \a obj. If there is no
+ default property, an invalid QmlMetaProperty will be created.
+ */
+QmlMetaProperty::QmlMetaProperty(QObject *obj)
+{
+ initDefault(obj);
+}
+
/*!
+ \internal
Creates a QmlMetaProperty for the default property of \a obj. If there is no
default property, an invalid QmlMetaProperty will be created.
*/
@@ -111,6 +122,11 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, QmlContext *ctxt)
: d(new QmlMetaPropertyPrivate)
{
d->context = ctxt;
+ initDefault(obj);
+}
+
+void QmlMetaProperty::initDefault(QObject *obj)
+{
if(!obj)
return;
@@ -162,6 +178,16 @@ static QHash<const QMetaObject *, QHash<QString, QMetaPropertyEx> > qmlCacheProp
/*!
Creates a QmlMetaProperty for the property \a name of \a obj.
*/
+QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name)
+: d(new QmlMetaPropertyPrivate)
+{
+ initProperty(obj, name);
+}
+
+/*!
+ \internal
+ Creates a QmlMetaProperty for the property \a name of \a obj.
+ */
QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name, QmlContext *ctxt)
: d(new QmlMetaPropertyPrivate)
{
@@ -170,6 +196,11 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name, QmlContext *
#endif
d->context = ctxt;
+ initProperty(obj, name);
+}
+
+void QmlMetaProperty::initProperty(QObject *obj, const QString &name)
+{
d->name = name;
d->object = obj;
if(name.isEmpty() || !obj)
diff --git a/src/declarative/qml/qmlmetaproperty.h b/src/declarative/qml/qmlmetaproperty.h
index a2939f9..4836038 100644
--- a/src/declarative/qml/qmlmetaproperty.h
+++ b/src/declarative/qml/qmlmetaproperty.h
@@ -72,8 +72,10 @@ public:
Normal
};
QmlMetaProperty();
- QmlMetaProperty(QObject *, QmlContext * = 0);
- QmlMetaProperty(QObject *, const QString &, QmlContext * = 0);
+ QmlMetaProperty(QObject *);
+ QmlMetaProperty(QObject *, const QString &);
+ QmlMetaProperty(QObject *, QmlContext *);
+ QmlMetaProperty(QObject *, const QString &, QmlContext *);
QmlMetaProperty(const QmlMetaProperty &);
QmlMetaProperty &operator=(const QmlMetaProperty &);
QmlMetaProperty(QObject *, int, PropertyCategory = Unknown, QmlContext * = 0);
@@ -125,6 +127,8 @@ public:
int coreIndex() const;
private:
+ void initDefault(QObject *obj);
+ void initProperty(QObject *obj, const QString &name);
friend class QmlEnginePrivate;
QmlMetaPropertyPrivate *d;
};