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.
|
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)
|
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);
|
Q_Q(QAbstractState);
|
||||||
emit q->entered(QAbstractState::QPrivateSignal());
|
emit q->entered(QAbstractState::QPrivateSignal());
|
||||||
|
if (!active) {
|
||||||
|
active = true;
|
||||||
|
emit q->activeChanged(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QAbstractStatePrivate::emitExited()
|
void QAbstractStatePrivate::emitExited()
|
||||||
{
|
{
|
||||||
Q_Q(QAbstractState);
|
Q_Q(QAbstractState);
|
||||||
|
if (active) {
|
||||||
|
active = false;
|
||||||
|
emit q->activeChanged(false);
|
||||||
|
}
|
||||||
emit q->exited(QAbstractState::QPrivateSignal());
|
emit q->exited(QAbstractState::QPrivateSignal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,6 +190,17 @@ QStateMachine *QAbstractState::machine() const
|
|||||||
return d->machine();
|
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)
|
\fn QAbstractState::onExit(QEvent *event)
|
||||||
|
|
||||||
@ -203,6 +231,15 @@ QStateMachine *QAbstractState::machine() const
|
|||||||
been called).
|
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
|
\reimp
|
||||||
*/
|
*/
|
||||||
|
@ -56,12 +56,15 @@ class QAbstractStatePrivate;
|
|||||||
class Q_CORE_EXPORT QAbstractState : public QObject
|
class Q_CORE_EXPORT QAbstractState : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool active READ active NOTIFY activeChanged)
|
||||||
public:
|
public:
|
||||||
~QAbstractState();
|
~QAbstractState();
|
||||||
|
|
||||||
QState *parentState() const;
|
QState *parentState() const;
|
||||||
QStateMachine *machine() const;
|
QStateMachine *machine() const;
|
||||||
|
|
||||||
|
bool active() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void entered(
|
void entered(
|
||||||
#if !defined(Q_QDOC)
|
#if !defined(Q_QDOC)
|
||||||
@ -73,6 +76,7 @@ Q_SIGNALS:
|
|||||||
QPrivateSignal
|
QPrivateSignal
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
void activeChanged(bool active);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QAbstractState(QState *parent = 0);
|
QAbstractState(QState *parent = 0);
|
||||||
|
@ -85,8 +85,9 @@ public:
|
|||||||
void emitEntered();
|
void emitEntered();
|
||||||
void emitExited();
|
void emitExited();
|
||||||
|
|
||||||
uint stateType:31;
|
uint stateType:30;
|
||||||
uint isMachine:1;
|
uint isMachine:1;
|
||||||
|
bool active:1;
|
||||||
mutable QState *parentState;
|
mutable QState *parentState;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1369,6 +1369,11 @@ void QStateMachinePrivate::_q_start()
|
|||||||
{
|
{
|
||||||
Q_Q(QStateMachine);
|
Q_Q(QStateMachine);
|
||||||
Q_ASSERT(state == Starting);
|
Q_ASSERT(state == Starting);
|
||||||
|
foreach (QAbstractState *state, configuration) {
|
||||||
|
QAbstractStatePrivate *abstractStatePrivate = QAbstractStatePrivate::get(state);
|
||||||
|
abstractStatePrivate->active = false;
|
||||||
|
emit state->activeChanged(false);
|
||||||
|
}
|
||||||
configuration.clear();
|
configuration.clear();
|
||||||
qDeleteAll(internalEventQueue);
|
qDeleteAll(internalEventQueue);
|
||||||
internalEventQueue.clear();
|
internalEventQueue.clear();
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user