From 22cd698e39970ded3fa4fd873195314015ce4b8c Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Fri, 8 Mar 2013 10:51:53 -0800 Subject: Document Q_REVISION macro better Previously it was only mentioned in properties.qdoc Task-number: QTBUG-18802 Change-Id: Iab23128c1567974154cdcce7412b2e1468bb846a Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmetaobject.cpp | 9 +++++---- src/corelib/kernel/qobject.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 4399349352..b581be821b 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -1904,9 +1904,9 @@ int QMetaMethod::methodIndex() const return QMetaMethodPrivate::get(this)->ownMethodIndex() + mobj->methodOffset(); } +// This method has been around for a while, but the documentation was marked \internal until 5.1 /*! - \internal - + \since 5.1 Returns the method revision if one was specified by Q_REVISION, otherwise returns 0. */ @@ -2550,7 +2550,7 @@ static QByteArray qualifiedName(const QMetaEnum &e) A property has a name() and a type(), as well as various attributes that specify its behavior: isReadable(), isWritable(), - isDesignable(), isScriptable(), and isStored(). + isDesignable(), isScriptable(), revision(), and isStored(). If the property is an enumeration, isEnumType() returns true; if the property is an enumeration that is also a flag (i.e. its values @@ -2994,8 +2994,9 @@ int QMetaProperty::notifySignalIndex() const } } +// This method has been around for a while, but the documentation was marked \internal until 5.1 /*! - \internal + \since 5.1 Returns the property revision if one was specified by REVISION, otherwise returns 0. diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 583e580762..527a842d17 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4102,6 +4102,37 @@ QDebug operator<<(QDebug dbg, const QObject *o) { be invoked using QMetaObject::invokeMethod(). */ +/*! + \macro Q_REVISION + \relates QObject + + Apply this macro to definitions of member functions to tag them with a + revision number in the meta-object system. The macro is written before + the return type, as shown in the following example: + + \snippet qmetaobject-revision/window.h Window class with revision + + This is useful when using the meta-object system to dynamically expose + objects to another API, as you can match the version expected by multiple + versions of the other API. Consider the following simplified example: + + \snippet qmetaobject-revision/main.cpp Window class using revision + + Using the same Window class as the previous example, the newProperty and + newMethod would only be exposed in this code when the expected version is + 1 or greater. + + Since all methods are considered to be in revision 0 if untagged, a tag + of Q_REVISION(0) is invalid and ignored. + + This tag is not used by the meta-object system itself. Currently this is only + used by the QtQml module. + + For a more generic string tag, see \l QMetaMethod::tag() + + \sa QMetaMethod::revision() +*/ + /*! \macro Q_SET_OBJECT_NAME(Object) \relates QObject -- cgit v1.2.3