diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-04-22 20:47:08 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-25 20:16:56 +0200 |
commit | 28c79d8c0bbe7d4316c52f0f6f5421c9aa724735 (patch) | |
tree | 0429012ccf81d45dbb4f6dcdb084ed275bd69302 /src | |
parent | 6624151c6a8772a3f01a291f744ea72b469106fc (diff) |
Add comparison operators == and != for QMetaMethod
This is done in preparation of introducing the
QObject::connectNotify(QMetaMethod) function. Together with the
forthcoming QMetaMethod::fromSignal() function, which returns the
QMetaMethod corresponding to a Qt/C++ signal (member function), the
comparison operators provide an effective way of checking which
signal was connected to.
Change-Id: I2de48628c4884a7174fb8574895f272cb3fe5634
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 18 | ||||
-rw-r--r-- | src/corelib/kernel/qmetaobject.h | 7 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 2439c22f74..359dbfcf23 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -1477,6 +1477,24 @@ bool QMetaObject::invokeMethod(QObject *obj, invoked), otherwise returns false. */ +/*! \fn bool operator==(const QMetaMethod &m1, const QMetaMethod &m2) + \since 5.0 + \relates QMetaMethod + \overload + + Returns true if method \a m1 is equal to method \a m2, + otherwise returns false. +*/ + +/*! \fn bool operator!=(const QMetaMethod &m1, const QMetaMethod &m2) + \since 5.0 + \relates QMetaMethod + \overload + + Returns true if method \a m1 is not equal to method \a m2, + otherwise returns false. +*/ + /*! \fn const QMetaObject *QMetaMethod::enclosingMetaObject() const \internal diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index 095b196dca..5204f04ca3 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -155,9 +155,16 @@ private: friend struct QMetaObject; friend struct QMetaObjectPrivate; friend class QObject; + friend bool operator==(const QMetaMethod &m1, const QMetaMethod &m2); + friend bool operator!=(const QMetaMethod &m1, const QMetaMethod &m2); }; Q_DECLARE_TYPEINFO(QMetaMethod, Q_MOVABLE_TYPE); +inline bool operator==(const QMetaMethod &m1, const QMetaMethod &m2) +{ return m1.mobj == m2.mobj && m1.handle == m2.handle; } +inline bool operator!=(const QMetaMethod &m1, const QMetaMethod &m2) +{ return !(m1 == m2); } + class Q_CORE_EXPORT QMetaEnum { public: |