summaryrefslogtreecommitdiffstats
path: root/src/corelib/statemachine
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-04-23 09:46:02 (GMT)
committerEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-04-23 09:46:02 (GMT)
commitad1441fcb1c66ddafd890c1aa22a631d12c4ee0d (patch)
tree07eb8ddd0b6976d001486ef536906ff1cdf7bdde /src/corelib/statemachine
parent404db2ceac0ad4770c77f42e8f8a9cd003b151a1 (diff)
downloadQt-ad1441fcb1c66ddafd890c1aa22a631d12c4ee0d.zip
Qt-ad1441fcb1c66ddafd890c1aa22a631d12c4ee0d.tar.gz
Qt-ad1441fcb1c66ddafd890c1aa22a631d12c4ee0d.tar.bz2
Remove API for setting specific restore policies on states. We have no clear
use case for this, so it has been removed. If the requirement arises we can add it back in later. Since it no longer makes sense to have it in QAbstractState, the RestorePolicy enum has been moved to QStateMachine.
Diffstat (limited to 'src/corelib/statemachine')
-rw-r--r--src/corelib/statemachine/qabstractstate.cpp60
-rw-r--r--src/corelib/statemachine/qabstractstate.h11
-rw-r--r--src/corelib/statemachine/qabstractstate_p.h1
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp54
-rw-r--r--src/corelib/statemachine/qstatemachine.h10
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h2
6 files changed, 44 insertions, 94 deletions
diff --git a/src/corelib/statemachine/qabstractstate.cpp b/src/corelib/statemachine/qabstractstate.cpp
index 030c63c..396063a 100644
--- a/src/corelib/statemachine/qabstractstate.cpp
+++ b/src/corelib/statemachine/qabstractstate.cpp
@@ -76,45 +76,7 @@ QT_BEGIN_NAMESPACE
function to perform custom processing when the state is exited.
*/
-/*!
- \enum QAbstractState::RestorePolicy
-
- This enum specifies the restore policy type for a state. The restore policy
- takes effect when the machine enters a state which sets one or more
- properties. If the restore policy of the state 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 has its restore policy
- set to DoNotRestoreProperties or when it 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. Once the property has been restored, the state machine will clear the
- initial value until it enters a new state which sets the property and which has RestoreProperties
- as its restore policy.
-
- \value GlobalRestorePolicy The restore policy for the state should be retrieved using
- QStateMachine::globalRestorePolicy()
- \value DoNotRestoreProperties The state machine should not save the initial values of properties
- set in the state and restore them later.
- \value RestoreProperties The state machine should save the initial values of properties
- set in the state and restore them later.
-
-
- \sa setRestorePolicy(), restorePolicy(), QAbstractState::assignProperty()
-*/
-
-/*!
- \property QAbstractState::restorePolicy
-
- \brief the restore policy of this state
-*/
-
-QAbstractStatePrivate::QAbstractStatePrivate()
- : restorePolicy(QAbstractState::GlobalRestorePolicy)
+QAbstractStatePrivate::QAbstractStatePrivate()
{
}
@@ -237,26 +199,6 @@ void QAbstractState::assignProperty(QObject *object, const char *name,
}
/*!
- Sets the restore policy of this state to \a restorePolicy.
-
- The default restore policy is QAbstractState::GlobalRestorePolicy.
-*/
-void QAbstractState::setRestorePolicy(RestorePolicy restorePolicy)
-{
- Q_D(QAbstractState);
- d->restorePolicy = restorePolicy;
-}
-
-/*!
- Returns the restore policy for this state.
-*/
-QAbstractState::RestorePolicy QAbstractState::restorePolicy() const
-{
- Q_D(const QAbstractState);
- return d->restorePolicy;
-}
-
-/*!
\fn QAbstractState::onExit()
This function is called when the state is exited. Reimplement this function
diff --git a/src/corelib/statemachine/qabstractstate.h b/src/corelib/statemachine/qabstractstate.h
index 55e9a62..69e6bf1 100644
--- a/src/corelib/statemachine/qabstractstate.h
+++ b/src/corelib/statemachine/qabstractstate.h
@@ -56,15 +56,7 @@ class QAbstractStatePrivate;
class Q_CORE_EXPORT QAbstractState : public QObject
{
Q_OBJECT
- Q_ENUMS(RestorePolicy)
- Q_PROPERTY(RestorePolicy restorePolicy READ restorePolicy WRITE setRestorePolicy)
public:
- enum RestorePolicy {
- GlobalRestorePolicy,
- DoNotRestoreProperties,
- RestoreProperties
- };
-
~QAbstractState();
QState *parentState() const;
@@ -72,9 +64,6 @@ public:
void assignProperty(QObject *object, const char *name,
const QVariant &value);
- void setRestorePolicy(RestorePolicy restorePolicy);
- RestorePolicy restorePolicy() const;
-
Q_SIGNALS:
void entered();
void exited();
diff --git a/src/corelib/statemachine/qabstractstate_p.h b/src/corelib/statemachine/qabstractstate_p.h
index e47fbd2..8c8f436 100644
--- a/src/corelib/statemachine/qabstractstate_p.h
+++ b/src/corelib/statemachine/qabstractstate_p.h
@@ -101,7 +101,6 @@ public:
void emitEntered();
void emitExited();
- QAbstractState::RestorePolicy restorePolicy;
QList<QPropertyAssignment> propertyAssignments;
#ifdef QT_STATEMACHINE_SOLUTION
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index b6ab205..2d3eea1 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -188,7 +188,7 @@ QStateMachinePrivate::QStateMachinePrivate()
processingScheduled = false;
stop = false;
error = QStateMachine::NoError;
- globalRestorePolicy = QAbstractState::DoNotRestoreProperties;
+ globalRestorePolicy = QStateMachine::DoNotRestoreProperties;
rootState = 0;
initialErrorStateForRoot = 0;
#ifndef QT_STATEMACHINE_SOLUTION
@@ -631,14 +631,10 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
for (int i = 0; i < enteredStates.size(); ++i) {
QAbstractState *s = enteredStates.at(i);
- QAbstractState::RestorePolicy restorePolicy = s->restorePolicy();
- if (restorePolicy == QAbstractState::GlobalRestorePolicy)
- restorePolicy = globalRestorePolicy;
-
QList<QPropertyAssignment> assignments = QAbstractStatePrivate::get(s)->propertyAssignments;
for (int j = 0; j < assignments.size(); ++j) {
const QPropertyAssignment &assn = assignments.at(j);
- if (restorePolicy == QAbstractState::RestoreProperties) {
+ if (globalRestorePolicy == QStateMachine::RestoreProperties) {
registerRestorable(assn.object, assn.propertyName);
}
pendingRestorables.remove(RestorableId(assn.object, assn.propertyName));
@@ -1458,6 +1454,32 @@ void QStateMachine::setErrorState(QAbstractState *state)
*/
/*!
+ \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 DoNotRestoreProperties 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 setRestorePolicy(), restorePolicy(), QAbstractState::assignProperty()
+*/
+
+
+/*!
Returns the error code of the last error that occurred in the state machine.
*/
QStateMachine::Error QStateMachine::error() const
@@ -1486,33 +1508,25 @@ void QStateMachine::clearError()
}
/*!
- Returns the global restore policy of the state machine.
+ Returns the restore policy of the state machine.
- \sa QAbstractState::restorePolicy()
+ \sa setGlobalRestorePolicy()
*/
-QAbstractState::RestorePolicy QStateMachine::globalRestorePolicy() const
+QStateMachine::RestorePolicy QStateMachine::globalRestorePolicy() const
{
Q_D(const QStateMachine);
return d->globalRestorePolicy;
}
/*!
- Sets the global restore policy of the state machine to \a restorePolicy. The default global
+ Sets the restore policy of the state machine to \a restorePolicy. The default
restore policy is QAbstractState::DoNotRestoreProperties.
- The global restore policy cannot be set to QAbstractState::GlobalRestorePolicy.
-
- \sa QAbstractState::setRestorePolicy()
+ \sa globalRestorePolicy()
*/
-void QStateMachine::setGlobalRestorePolicy(QAbstractState::RestorePolicy restorePolicy)
+void QStateMachine::setGlobalRestorePolicy(QStateMachine::RestorePolicy restorePolicy)
{
Q_D(QStateMachine);
- if (restorePolicy == QState::GlobalRestorePolicy) {
- qWarning("QStateMachine::setGlobalRestorePolicy: Cannot set global restore policy to "
- "GlobalRestorePolicy");
- return;
- }
-
d->globalRestorePolicy = restorePolicy;
}
diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h
index 901d160..9a7a6fc 100644
--- a/src/corelib/statemachine/qstatemachine.h
+++ b/src/corelib/statemachine/qstatemachine.h
@@ -72,7 +72,13 @@ class Q_CORE_EXPORT QStateMachine : public QObject
Q_PROPERTY(QAbstractState* initialState READ initialState WRITE setInitialState)
Q_PROPERTY(QAbstractState* errorState READ errorState WRITE setErrorState)
Q_PROPERTY(QString errorString READ errorString)
+ Q_PROPERTY(RestorePolicy globalRestorePolicy READ globalRestorePolicy WRITE setGlobalRestorePolicy)
+ Q_ENUMS(RestorePolicy)
public:
+ enum RestorePolicy {
+ DoNotRestoreProperties,
+ RestoreProperties
+ };
enum Error {
NoError,
@@ -112,8 +118,8 @@ public:
void removeDefaultAnimationForTargetState(QAbstractState *targetState, QAbstractAnimation *animation);
#endif // QT_NO_ANIMATION
- QAbstractState::RestorePolicy globalRestorePolicy() const;
- void setGlobalRestorePolicy(QAbstractState::RestorePolicy restorePolicy);
+ QStateMachine::RestorePolicy globalRestorePolicy() const;
+ void setGlobalRestorePolicy(QStateMachine::RestorePolicy restorePolicy);
void postEvent(QEvent *event, int delay = 0);
diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h
index 910b751..9f93217 100644
--- a/src/corelib/statemachine/qstatemachine_p.h
+++ b/src/corelib/statemachine/qstatemachine_p.h
@@ -171,7 +171,7 @@ public:
QList<QEvent*> externalEventQueue;
QStateMachine::Error error;
- QAbstractState::RestorePolicy globalRestorePolicy;
+ QStateMachine::RestorePolicy globalRestorePolicy;
QString errorString;
QSet<QAbstractState *> pendingErrorStates;