summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2009-05-18 07:08:17 (GMT)
committerKai Koehne <kai.koehne@nokia.com>2009-05-18 07:14:04 (GMT)
commit6210f1508da2d62614e0e9d35e5036a3ab9ee247 (patch)
treee825c7defe1a4e7c58ec79cd179e3dce15162f0b /src
parent0add74a9339a9d7dda302aa4f31cbb50bdb69908 (diff)
downloadQt-6210f1508da2d62614e0e9d35e5036a3ab9ee247.zip
Qt-6210f1508da2d62614e0e9d35e5036a3ab9ee247.tar.gz
Qt-6210f1508da2d62614e0e9d35e5036a3ab9ee247.tar.bz2
Allow mapping from QMetaObject * to corresponding QmlType
This is needed in Bauhaus to get the QmlType of a parent QMetaObject. Also, mark QmlType class as to be exported. Reviewed-by: Aaron Kennedy
Diffstat (limited to 'src')
-rw-r--r--src/declarative/qml/qmlmetatype.cpp12
-rw-r--r--src/declarative/qml/qmlmetatype.h6
2 files changed, 14 insertions, 4 deletions
diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp
index 7825e5c..df61a82 100644
--- a/src/declarative/qml/qmlmetatype.cpp
+++ b/src/declarative/qml/qmlmetatype.cpp
@@ -95,8 +95,8 @@ struct QmlMetaTypeData
QBitArray qmllists;
QBitArray lists;
};
-Q_GLOBAL_STATIC(QmlMetaTypeData, metaTypeData);
-Q_GLOBAL_STATIC(QReadWriteLock, metaTypeDataLock);
+Q_GLOBAL_STATIC(QmlMetaTypeData, metaTypeData)
+Q_GLOBAL_STATIC(QReadWriteLock, metaTypeDataLock)
class QmlTypePrivate
{
@@ -864,6 +864,14 @@ QmlType *QmlMetaType::qmlType(const QByteArray &name)
return data->nameToType.value(name);
}
+QmlType *QmlMetaType::qmlType(const QMetaObject *metaObject)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QmlMetaTypeData *data = metaTypeData();
+
+ return data->metaObjectToType.value(metaObject);
+}
+
QList<QByteArray> QmlMetaType::qmlTypeNames()
{
QReadLocker lock(metaTypeDataLock());
diff --git a/src/declarative/qml/qmlmetatype.h b/src/declarative/qml/qmlmetatype.h
index 7ab01a5..cc3887c 100644
--- a/src/declarative/qml/qmlmetatype.h
+++ b/src/declarative/qml/qmlmetatype.h
@@ -64,9 +64,11 @@ public:
static bool copy(int type, void *data, const void *copy = 0);
- static QmlType *qmlType(const QByteArray &);
static QList<QByteArray> qmlTypeNames();
+ static QmlType *qmlType(const QByteArray &);
+ static QmlType *qmlType(const QMetaObject *);
+
static QMetaProperty defaultProperty(const QMetaObject *);
static QMetaProperty defaultProperty(QObject *);
static QMetaMethod defaultMethod(const QMetaObject *);
@@ -108,7 +110,7 @@ public:
};
class QmlTypePrivate;
-class QmlType
+class Q_DECLARATIVE_EXPORT QmlType
{
public:
QByteArray typeName() const;