Export QAbstractState active property.
It is needed to check if a State is active. Change-Id: I8aa0230b8cd96fb9b95b86b2ce118fe280f9ce97 Reviewed-by: Alan Alpert <aalpert@blackberry.com>
This commit is contained in:
parent
c67f7c0f0f
commit
f5edb62cc2
@ -79,8 +79,17 @@ QT_BEGIN_NAMESPACE
|
||||
function to perform custom processing when the state is exited.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QAbstractState::active
|
||||
\since 5.4
|
||||
|
||||
\brief the active property of this state. A state is active between
|
||||
entered() and exited() signals.
|
||||
*/
|
||||
|
||||
|
||||
QAbstractStatePrivate::QAbstractStatePrivate(StateType type)
|
||||
: stateType(type), isMachine(false), parentState(0)
|
||||
: stateType(type), isMachine(false), active(false), parentState(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -121,11 +130,19 @@ void QAbstractStatePrivate::emitEntered()
|
||||
{
|
||||
Q_Q(QAbstractState);
|
||||
emit q->entered(QAbstractState::QPrivateSignal());
|
||||
if (!active) {
|
||||
active = true;
|
||||
emit q->activeChanged(true);
|
||||
}
|
||||
}
|
||||
|
||||
void QAbstractStatePrivate::emitExited()
|
||||
{
|
||||
Q_Q(QAbstractState);
|
||||
if (active) {
|
||||
active = false;
|
||||
emit q->activeChanged(false);
|
||||
}
|
||||
emit q->exited(QAbstractState::QPrivateSignal());
|
||||
}
|
||||
|
||||
@ -173,6 +190,17 @@ QStateMachine *QAbstractState::machine() const
|
||||
return d->machine();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns whether this state is active.
|
||||
|
||||
\sa activeChanged(bool), entered(), exited()
|
||||
*/
|
||||
bool QAbstractState::active() const
|
||||
{
|
||||
Q_D(const QAbstractState);
|
||||
return d->active;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QAbstractState::onExit(QEvent *event)
|
||||
|
||||
@ -203,6 +231,15 @@ QStateMachine *QAbstractState::machine() const
|
||||
been called).
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QAbstractState::activeChanged(bool active)
|
||||
\since 5.4
|
||||
|
||||
This signal is emitted when the active property is changed.
|
||||
|
||||
\sa QAbstractState::active, entered(), exited()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
|
@ -56,12 +56,15 @@ class QAbstractStatePrivate;
|
||||
class Q_CORE_EXPORT QAbstractState : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool active READ active NOTIFY activeChanged)
|
||||
public:
|
||||
~QAbstractState();
|
||||
|
||||
QState *parentState() const;
|
||||
QStateMachine *machine() const;
|
||||
|
||||
bool active() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void entered(
|
||||
#if !defined(Q_QDOC)
|
||||
@ -73,6 +76,7 @@ Q_SIGNALS:
|
||||
QPrivateSignal
|
||||
#endif
|
||||
);
|
||||
void activeChanged(bool active);
|
||||
|
||||
protected:
|
||||
QAbstractState(QState *parent = 0);
|
||||
|
@ -85,8 +85,9 @@ public:
|
||||
void emitEntered();
|
||||
void emitExited();
|
||||
|
||||
uint stateType:31;
|
||||
uint stateType:30;
|
||||
uint isMachine:1;
|
||||
bool active:1;
|
||||
mutable QState *parentState;
|
||||
};
|
||||
|
||||
|
@ -1369,6 +1369,11 @@ void QStateMachinePrivate::_q_start()
|
||||
{
|
||||
Q_Q(QStateMachine);
|
||||
Q_ASSERT(state == Starting);
|
||||
foreach (QAbstractState *state, configuration) {
|
||||
QAbstractStatePrivate *abstractStatePrivate = QAbstractStatePrivate::get(state);
|
||||
abstractStatePrivate->active = false;
|
||||
emit state->activeChanged(false);
|
||||
}
|
||||
configuration.clear();
|
||||
qDeleteAll(internalEventQueue);
|
||||
internalEventQueue.clear();
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user