summaryrefslogtreecommitdiffstats
path: root/src/corelib/statemachine
diff options
context:
space:
mode:
authorBogDan Vatra <bogdan.vatra@kdab.com>2014-06-23 15:54:24 +0300
committerBogDan Vatra <bogdan@kde.org>2014-06-25 16:24:47 +0200
commitdd70e2cb0f84bee434f2f7fb69a26732214ce690 (patch)
tree25f519e280bebee75c925a9c934a989ad52841b1 /src/corelib/statemachine
parent7fa584254c3ed17b65211c6ae8e05bea66393d93 (diff)
Emit a notifications when childMode, initial and errorState are changed.
In order to properly use QState object in QML we need to know when these properties are changed. Change-Id: I37f8295e5201686a52d448cc42db331a8f8e792f Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Alan Alpert <aalpert@blackberry.com> Reviewed-by: BogDan Vatra <bogdan@kde.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/corelib/statemachine')
-rw-r--r--src/corelib/statemachine/qstate.cpp42
-rw-r--r--src/corelib/statemachine/qstate.h21
2 files changed, 57 insertions, 6 deletions
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp
index f3b4c5f235..e9baddc569 100644
--- a/src/corelib/statemachine/qstate.cpp
+++ b/src/corelib/statemachine/qstate.cpp
@@ -309,7 +309,10 @@ void QState::setErrorState(QAbstractState *state)
return;
}
- d->errorState = state;
+ if (d->errorState != state) {
+ d->errorState = state;
+ emit errorStateChanged(QState::QPrivateSignal());
+ }
}
/*!
@@ -491,7 +494,10 @@ void QState::setInitialState(QAbstractState *state)
state, this);
return;
}
- d->initialState = state;
+ if (d->initialState != state) {
+ d->initialState = state;
+ emit initialStateChanged(QState::QPrivateSignal());
+ }
}
/*!
@@ -509,7 +515,10 @@ QState::ChildMode QState::childMode() const
void QState::setChildMode(ChildMode mode)
{
Q_D(QState);
- d->childMode = mode;
+ if (d->childMode != mode) {
+ d->childMode = mode;
+ emit childModeChanged(QState::QPrivateSignal());
+ }
}
/*!
@@ -549,6 +558,33 @@ bool QState::event(QEvent *e)
\sa QState::assignProperty(), QAbstractTransition::addAnimation()
*/
+/*!
+ \fn QState::childModeChanged()
+ \since 5.4
+
+ This signal is emitted when the childMode property is changed.
+
+ \sa QState::childMode
+*/
+
+/*!
+ \fn QState::initialStateChanged()
+ \since 5.4
+
+ This signal is emitted when the initialState property is changed.
+
+ \sa QState::initialState
+*/
+
+/*!
+ \fn QState::errorStateChanged()
+ \since 5.4
+
+ This signal is emitted when the errorState property is changed.
+
+ \sa QState::errorState
+*/
+
QT_END_NAMESPACE
#endif //QT_NO_STATEMACHINE
diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h
index a5f2509ffb..09c98c30c6 100644
--- a/src/corelib/statemachine/qstate.h
+++ b/src/corelib/statemachine/qstate.h
@@ -58,9 +58,9 @@ class QStatePrivate;
class Q_CORE_EXPORT QState : public QAbstractState
{
Q_OBJECT
- Q_PROPERTY(QAbstractState* initialState READ initialState WRITE setInitialState)
- Q_PROPERTY(QAbstractState* errorState READ errorState WRITE setErrorState)
- Q_PROPERTY(ChildMode childMode READ childMode WRITE setChildMode)
+ Q_PROPERTY(QAbstractState* initialState READ initialState WRITE setInitialState NOTIFY initialStateChanged)
+ Q_PROPERTY(QAbstractState* errorState READ errorState WRITE setErrorState NOTIFY errorStateChanged)
+ Q_PROPERTY(ChildMode childMode READ childMode WRITE setChildMode NOTIFY childModeChanged)
Q_ENUMS(ChildMode RestorePolicy)
public:
enum ChildMode {
@@ -108,6 +108,21 @@ Q_SIGNALS:
QPrivateSignal
#endif
);
+ void childModeChanged(
+#if !defined(Q_QDOC)
+ QPrivateSignal
+#endif
+ );
+ void initialStateChanged(
+#if !defined(Q_QDOC)
+ QPrivateSignal
+#endif
+ );
+ void errorStateChanged(
+#if !defined(Q_QDOC)
+ QPrivateSignal
+#endif
+ );
protected:
void onEntry(QEvent *event);