diff options
author | André Klitzing <aklitzing@gmail.com> | 2014-12-10 15:18:49 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2014-12-20 06:36:26 +0100 |
commit | ebd33883e79b458639e8fe118ccc285641223203 (patch) | |
tree | 224f18a9c940f39e19b2edadef4e89109633a5b1 /src/corelib | |
parent | 86d04cfe2bdceca401cab228bd63245f16e65731 (diff) |
QState: Added template PointerToMemberFunction
Added the function pointer to addTransition to take
advantage of the new connect syntax.
[ChangeLog][QtCore][State Machine] Added an addTransition() overload that
takes a pointer-to-member for the signal triggering the transition.
Change-Id: Ic97f7983839217ca0c8484b269d38221cbe804e3
Task-number: QTBUG-40293
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/statemachine/qstate.cpp | 11 | ||||
-rw-r--r-- | src/corelib/statemachine/qstate.h | 14 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp index b68dc88fb1..15f6e29fcb 100644 --- a/src/corelib/statemachine/qstate.cpp +++ b/src/corelib/statemachine/qstate.cpp @@ -339,6 +339,17 @@ void QState::addTransition(QAbstractTransition *transition) } /*! + \fn QState::addTransition(const QObject *sender, PointerToMemberFunction signal, + QAbstractState *target); + \since 5.5 + \overload + + Adds a transition associated with the given \a signal of the given \a sender + object, and returns the new QSignalTransition object. The transition has + this state as the source, and the given \a target as the target state. +*/ + +/*! Adds a transition associated with the given \a signal of the given \a sender object, and returns the new QSignalTransition object. The transition has this state as the source, and the given \a target as the target state. diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h index a9fd04bf00..8a308cf38e 100644 --- a/src/corelib/statemachine/qstate.h +++ b/src/corelib/statemachine/qstate.h @@ -35,8 +35,8 @@ #define QSTATE_H #include <QtCore/qabstractstate.h> - #include <QtCore/qlist.h> +#include <QtCore/qmetaobject.h> QT_BEGIN_NAMESPACE @@ -74,6 +74,18 @@ public: void addTransition(QAbstractTransition *transition); QSignalTransition *addTransition(const QObject *sender, const char *signal, QAbstractState *target); +#ifdef Q_QDOC + QSignalTransition *addTransition(const QObject *sender, PointerToMemberFunction signal, + QAbstractState *target); +#else + template <typename Func> + QSignalTransition *addTransition(const typename QtPrivate::FunctionPointer<Func>::Object *obj, + Func signal, QAbstractState *target) + { + const QMetaMethod signalMetaMethod = QMetaMethod::fromSignal(signal); + return addTransition(obj, signalMetaMethod.methodSignature().constData(), target); + } +#endif // Q_QDOC QAbstractTransition *addTransition(QAbstractState *target); void removeTransition(QAbstractTransition *transition); QList<QAbstractTransition*> transitions() const; |