window.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
QState *group = new QState(&machine);
group->setObjectName("group");
is entered, all its child states are entered in parallel.
*/
+/*!
+ \enum QState::RestorePolicy
+
+ This enum specifies the restore policy type. The restore policy
+ takes effect when the machine enters a state which sets one or more
+ properties. If the restore policy is set to RestoreProperties,
+ the state machine will save the original value of the property before the
+ new value is set.
+
+ Later, when the machine either enters a state which does not set
+ a value for the given property, the property will automatically be restored
+ to its initial value.
+
+ Only one initial value will be saved for any given property. If a value for a property has
+ already been saved by the state machine, it will not be overwritten until the property has been
+ successfully restored.
+
+ \value DontRestoreProperties The state machine should not save the initial values of properties
+ and restore them later.
+ \value RestoreProperties The state machine should save the initial values of properties
+ and restore them later.
+
+ \sa QStateMachine::globalRestorePolicy, QState::assignProperty()
+*/
+
QStatePrivate::QStatePrivate()
: QAbstractStatePrivate(StandardState),
errorState(0), initialState(0), childMode(QState::ExclusiveStates),
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_ENUMS(ChildMode)
+ Q_ENUMS(ChildMode RestorePolicy)
public:
enum ChildMode {
ExclusiveStates,
ParallelStates
};
+ enum RestorePolicy {
+ DontRestoreProperties,
+ RestoreProperties
+ };
+
QState(QState *parent = 0);
QState(ChildMode childMode, QState *parent = 0);
~QState();
\brief the restore policy for states of this state machine.
The default value of this property is
- QStateMachine::DontRestoreProperties.
+ QState::DontRestoreProperties.
*/
#ifndef QT_NO_ANIMATION
stop = false;
stopProcessingReason = EventQueueEmpty;
error = QStateMachine::NoError;
- globalRestorePolicy = QStateMachine::DontRestoreProperties;
+ globalRestorePolicy = QState::DontRestoreProperties;
signalEventGenerator = 0;
#ifndef QT_NO_ANIMATION
animated = true;
QList<QPropertyAssignment> assignments = propertyAssignmentsForState.value(s);
for (int i = 0; i < assignments.size(); ++i) {
const QPropertyAssignment &assn = assignments.at(i);
- if (globalRestorePolicy == QStateMachine::RestoreProperties) {
+ if (globalRestorePolicy == QState::RestoreProperties) {
if (assn.explicitlySet) {
if (!hasRestorable(s, assn.object, assn.propertyName)) {
QVariant value = savedValueForRestorable(exitedStates_sorted, assn.object, assn.propertyName);
// ### connect to just the top-level animation?
QObject::connect(a, SIGNAL(finished()), q, SLOT(_q_animationFinished()), Qt::UniqueConnection);
}
- if ((globalRestorePolicy == QStateMachine::RestoreProperties)
+ if ((globalRestorePolicy == QState::RestoreProperties)
&& !hasRestorable(state, assn.object, assn.propertyName)) {
QVariant value = savedValueForRestorable(exitedStates_sorted, assn.object, assn.propertyName);
unregisterRestorables(exitedStates_sorted, assn.object, assn.propertyName);
*/
/*!
- \enum QStateMachine::RestorePolicy
-
- This enum specifies the restore policy type. The restore policy
- takes effect when the machine enters a state which sets one or more
- properties. If the restore policy is set to RestoreProperties,
- the state machine will save the original value of the property before the
- new value is set.
-
- Later, when the machine either enters a state which does not set
- a value for the given property, the property will automatically be restored
- to its initial value.
-
- Only one initial value will be saved for any given property. If a value for a property has
- already been saved by the state machine, it will not be overwritten until the property has been
- successfully restored.
-
- \value DontRestoreProperties The state machine should not save the initial values of properties
- and restore them later.
- \value RestoreProperties The state machine should save the initial values of properties
- and restore them later.
-
- \sa QStateMachine::globalRestorePolicy, QState::assignProperty()
-*/
-
-
-/*!
Returns the error code of the last error that occurred in the state machine.
*/
QStateMachine::Error QStateMachine::error() const
\sa setGlobalRestorePolicy()
*/
-QStateMachine::RestorePolicy QStateMachine::globalRestorePolicy() const
+QState::RestorePolicy QStateMachine::globalRestorePolicy() const
{
Q_D(const QStateMachine);
return d->globalRestorePolicy;
/*!
Sets the restore policy of the state machine to \a restorePolicy. The default
- restore policy is QAbstractState::DontRestoreProperties.
+ restore policy is QState::DontRestoreProperties.
\sa globalRestorePolicy()
*/
-void QStateMachine::setGlobalRestorePolicy(QStateMachine::RestorePolicy restorePolicy)
+void QStateMachine::setGlobalRestorePolicy(QState::RestorePolicy restorePolicy)
{
Q_D(QStateMachine);
d->globalRestorePolicy = restorePolicy;
{
Q_OBJECT
Q_PROPERTY(QString errorString READ errorString)
- Q_PROPERTY(RestorePolicy globalRestorePolicy READ globalRestorePolicy WRITE setGlobalRestorePolicy)
- Q_ENUMS(RestorePolicy)
+ Q_PROPERTY(QState::RestorePolicy globalRestorePolicy READ globalRestorePolicy WRITE setGlobalRestorePolicy)
#ifndef QT_NO_ANIMATION
Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated)
#endif
HighPriority
};
- enum RestorePolicy {
- DontRestoreProperties,
- RestoreProperties
- };
-
enum Error {
NoError,
NoInitialStateError,
void removeDefaultAnimation(QAbstractAnimation *animation);
#endif // QT_NO_ANIMATION
- QStateMachine::RestorePolicy globalRestorePolicy() const;
- void setGlobalRestorePolicy(QStateMachine::RestorePolicy restorePolicy);
+ QState::RestorePolicy globalRestorePolicy() const;
+ void setGlobalRestorePolicy(QState::RestorePolicy restorePolicy);
void postEvent(QEvent *event, EventPriority priority = NormalPriority);
int postDelayedEvent(QEvent *event, int delay);
QMutex externalEventMutex;
QStateMachine::Error error;
- QStateMachine::RestorePolicy globalRestorePolicy;
+ QState::RestorePolicy globalRestorePolicy;
QString errorString;
QSet<QAbstractState *> pendingErrorStates;
void tst_QStateMachine::restoreProperties()
{
QStateMachine machine;
- QCOMPARE(machine.globalRestorePolicy(), QStateMachine::DontRestoreProperties);
- machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+ QCOMPARE(machine.globalRestorePolicy(), QState::DontRestoreProperties);
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
QObject *object = new QObject(&machine);
object->setProperty("a", 1);
void tst_QStateMachine::globalRestorePolicySetToDontRestore()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::DontRestoreProperties);
+ machine.setGlobalRestorePolicy(QState::DontRestoreProperties);
QObject *propertyHolder = new QObject(&machine);
propertyHolder->setProperty("a", 1);
void tst_QStateMachine::globalRestorePolicySetToRestore()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
QObject *propertyHolder = new QObject(&machine);
propertyHolder->setProperty("a", 1);
void tst_QStateMachine::animatedGlobalRestoreProperty()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
QObject *object = new QObject(&machine);
object->setProperty("foo", 1.0);
void tst_QStateMachine::nestedRestoreProperties()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
QObject *propertyHolder = new QObject(&machine);
propertyHolder->setProperty("foo", 1);
void tst_QStateMachine::nestedRestoreProperties2()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
QObject *propertyHolder = new QObject(&machine);
propertyHolder->setProperty("foo", 1);
void tst_QStateMachine::deletePropertyAssignmentObjectBeforeRestore()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
QState *s1 = new QState(&machine);
machine.setInitialState(s1);
QState *s2 = new QState(&machine);
void tst_QStateMachine::setPropertyAfterRestore()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
QObject *object = new QObject(&machine);
object->setProperty("a", 1);
void tst_QStateMachine::transitionWithNoTarget_data()
{
QTest::addColumn<int>("restorePolicy");
- QTest::newRow("DontRestoreProperties") << int(QStateMachine::DontRestoreProperties);
- QTest::newRow("RestoreProperties") << int(QStateMachine::RestoreProperties);
+ QTest::newRow("DontRestoreProperties") << int(QState::DontRestoreProperties);
+ QTest::newRow("RestoreProperties") << int(QState::RestoreProperties);
}
void tst_QStateMachine::transitionWithNoTarget()
QFETCH(int, restorePolicy);
QStateMachine machine;
- machine.setGlobalRestorePolicy(static_cast<QStateMachine::RestorePolicy>(restorePolicy));
+ machine.setGlobalRestorePolicy(static_cast<QState::RestorePolicy>(restorePolicy));
QObject *object = new QObject;
object->setProperty("a", 1);
void tst_QStateMachine::restorePropertiesSimple()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
PropertyObject *po = new PropertyObject;
po->setProp(2);
void tst_QStateMachine::restoreProperties2()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
PropertyObject *po = new PropertyObject;
po->setProp(2);
void tst_QStateMachine::restoreProperties3()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
PropertyObject *po = new PropertyObject;
po->setProp(2);
void tst_QStateMachine::restoreProperties4()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
PropertyObject *po1 = new PropertyObject;
po1->setProp(2);
void tst_QStateMachine::restorePropertiesSelfTransition()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
PropertyObject *po = new PropertyObject;
po->setProp(2);
void tst_QStateMachine::changeStateWhileAnimatingProperty()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
QObject *o1 = new QObject;
o1->setProperty("x", 10.);
void tst_QStateMachine::propertiesAreAssignedBeforeEntryCallbacks_data()
{
QTest::addColumn<int>("restorePolicy");
- QTest::newRow("DontRestoreProperties") << int(QStateMachine::DontRestoreProperties);
- QTest::newRow("RestoreProperties") << int(QStateMachine::RestoreProperties);
+ QTest::newRow("DontRestoreProperties") << int(QState::DontRestoreProperties);
+ QTest::newRow("RestoreProperties") << int(QState::RestoreProperties);
}
void tst_QStateMachine::propertiesAreAssignedBeforeEntryCallbacks()
QFETCH(int, restorePolicy);
QStateMachine machine;
- machine.setGlobalRestorePolicy(static_cast<QStateMachine::RestorePolicy>(restorePolicy));
+ machine.setGlobalRestorePolicy(static_cast<QState::RestorePolicy>(restorePolicy));
AssignPropertyTestState *s1 = new AssignPropertyTestState(&machine);
s1->assignProperty(s1, "wasAssigned", true);