From 1ab70725f76433a0f601fdfd70abc55bd6228ac3 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 18 Aug 2009 09:05:07 +0200 Subject: Make qml metatype db fully discoverable again Allow access to all registered types, and also expose the exact version range a type is provided for. --- src/declarative/qml/qmlmetatype.cpp | 23 +++++++++++++++++++++++ src/declarative/qml/qmlmetatype.h | 5 +++++ 2 files changed, 28 insertions(+) diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index 5ebe970..091bd1b 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -190,6 +190,21 @@ QmlType::~QmlType() delete d; } +int QmlType::majorVersion() const +{ + return d->m_version_maj; +} + +int QmlType::minMinorVersion() const +{ + return d->m_version_min_from; +} + +int QmlType::maxMinorVersion() const +{ + return d->m_version_min_to; +} + bool QmlType::availableInVersion(int vmajor, int vminor) const { return vmajor == d->m_version_maj && vminor >= d->m_version_min_from && vminor <= d->m_version_min_to; @@ -879,6 +894,14 @@ QList QmlMetaType::qmlTypeNames() return data->nameToType.keys(); } +QList QmlMetaType::qmlTypes() +{ + QReadLocker lock(metaTypeDataLock()); + QmlMetaTypeData *data = metaTypeData(); + + return data->nameToType.values(); +} + /*! Copies \a copy into \a data, assuming they both are of type \a type. If \a copy is zero, a default type is copied. Returns true if the copy was diff --git a/src/declarative/qml/qmlmetatype.h b/src/declarative/qml/qmlmetatype.h index 94029ce..c388b1a 100644 --- a/src/declarative/qml/qmlmetatype.h +++ b/src/declarative/qml/qmlmetatype.h @@ -65,6 +65,7 @@ public: static bool copy(int type, void *data, const void *copy = 0); static QList qmlTypeNames(); + static QList qmlTypes(); static QmlType *qmlType(const QByteArray &, int, int); static QmlType *qmlType(const QMetaObject *); @@ -111,6 +112,10 @@ class Q_DECLARATIVE_EXPORT QmlType public: QByteArray typeName() const; QByteArray qmlTypeName() const; + + int majorVersion() const; + int minMinorVersion() const; + int maxMinorVersion() const; bool availableInVersion(int vmajor, int vminor) const; QByteArray hash() const; -- cgit v0.12