From dd1598e1aaaf5630e688dc896d6f25c8a1e50ce2 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Fri, 27 Jun 2014 17:48:28 +0300 Subject: [PATCH] Emit a notifications when senderObject and signal are changed. In order to properly use QSignalTransition object in QML we need to know when these properties are changed. Change-Id: I7ca318d50513086146b85eaeee4dabbcdef8c299 Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Kevin Funk --- .../statemachine/qsignaltransition.cpp | 21 +++++++++++++++++++ src/corelib/statemachine/qsignaltransition.h | 17 +++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/corelib/statemachine/qsignaltransition.cpp b/src/corelib/statemachine/qsignaltransition.cpp index f1f4786bcc..259aaf52e9 100644 --- a/src/corelib/statemachine/qsignaltransition.cpp +++ b/src/corelib/statemachine/qsignaltransition.cpp @@ -185,6 +185,7 @@ void QSignalTransition::setSenderObject(const QObject *sender) d->unregister(); d->sender = sender; d->maybeRegister(); + emit senderObjectChanged(QPrivateSignal()); } /*! @@ -207,6 +208,7 @@ void QSignalTransition::setSignal(const QByteArray &signal) d->unregister(); d->signal = signal; d->maybeRegister(); + emit signalChanged(QPrivateSignal()); } /*! @@ -245,6 +247,24 @@ bool QSignalTransition::event(QEvent *e) return QAbstractTransition::event(e); } +/*! + \fn QSignalTransition::senderObjectChanged() + \since 5.4 + + This signal is emitted when the senderObject property is changed. + + \sa QSignalTransition::senderObject +*/ + +/*! + \fn QSignalTransition::signalChanged() + \since 5.4 + + This signal is emitted when the signal property is changed. + + \sa QSignalTransition::signal +*/ + void QSignalTransitionPrivate::callOnTransition(QEvent *e) { Q_Q(QSignalTransition); @@ -260,6 +280,7 @@ void QSignalTransitionPrivate::callOnTransition(QEvent *e) } } + QT_END_NAMESPACE #endif //QT_NO_STATEMACHINE diff --git a/src/corelib/statemachine/qsignaltransition.h b/src/corelib/statemachine/qsignaltransition.h index 12f021d78e..792fb12a14 100644 --- a/src/corelib/statemachine/qsignaltransition.h +++ b/src/corelib/statemachine/qsignaltransition.h @@ -53,8 +53,9 @@ class QSignalTransitionPrivate; class Q_CORE_EXPORT QSignalTransition : public QAbstractTransition { Q_OBJECT - Q_PROPERTY(QObject* senderObject READ senderObject WRITE setSenderObject) - Q_PROPERTY(QByteArray signal READ signal WRITE setSignal) + Q_PROPERTY(QObject* senderObject READ senderObject WRITE setSenderObject NOTIFY senderObjectChanged) + Q_PROPERTY(QByteArray signal READ signal WRITE setSignal NOTIFY signalChanged) + public: QSignalTransition(QState *sourceState = 0); QSignalTransition(const QObject *sender, const char *signal, @@ -73,6 +74,18 @@ protected: bool event(QEvent *e); +Q_SIGNALS: + void senderObjectChanged( +#if !defined(Q_QDOC) + QPrivateSignal +#endif + ); + void signalChanged( +#if !defined(Q_QDOC) + QPrivateSignal +#endif + ); + private: Q_DISABLE_COPY(QSignalTransition) Q_DECLARE_PRIVATE(QSignalTransition)