Go to the
documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QSTATEMACHINE_H
00043 #define QSTATEMACHINE_H
00044
00045 #include <QtCore/qstate.h>
00046
00047 #include <QtCore/qcoreevent.h>
00048 #include <QtCore/qlist.h>
00049 #include <QtCore/qobject.h>
00050 #include <QtCore/qset.h>
00051 #include <QtCore/qvariant.h>
00052
00053 QT_BEGIN_HEADER
00054
00055 QT_BEGIN_NAMESPACE
00056
00057 QT_MODULE(Core)
00058
00059 #ifndef QT_NO_STATEMACHINE
00060
00061 class QStateMachinePrivate;
00062 class QAbstractAnimation;
00063 class Q_CORE_EXPORT QStateMachine : public QState
00064 {
00065 Q_OBJECT
00066 Q_PROPERTY(QString errorString READ errorString)
00067 Q_PROPERTY(RestorePolicy globalRestorePolicy READ globalRestorePolicy WRITE setGlobalRestorePolicy)
00068 Q_ENUMS(RestorePolicy)
00069 #ifndef QT_NO_ANIMATION
00070 Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated)
00071 #endif
00072 public:
00073 class Q_CORE_EXPORT SignalEvent : public QEvent
00074 {
00075 public:
00076 SignalEvent(QObject *sender, int signalIndex,
00077 const QList<QVariant> &arguments);
00078 ~SignalEvent();
00079
00080 inline QObject *sender() const { return m_sender; }
00081 inline int signalIndex() const { return m_signalIndex; }
00082 inline QList<QVariant> arguments() const { return m_arguments; }
00083
00084 private:
00085 QObject *m_sender;
00086 int m_signalIndex;
00087 QList<QVariant> m_arguments;
00088
00089 friend class QSignalTransitionPrivate;
00090 };
00091
00092 class Q_CORE_EXPORT WrappedEvent : public QEvent
00093 {
00094 public:
00095 WrappedEvent(QObject *object, QEvent *event);
00096 ~WrappedEvent();
00097
00098 inline QObject *object() const { return m_object; }
00099 inline QEvent *event() const { return m_event; }
00100
00101 private:
00102 QObject *m_object;
00103 QEvent *m_event;
00104 };
00105
00106 enum EventPriority {
00107 NormalPriority,
00108 HighPriority
00109 };
00110
00111 enum RestorePolicy {
00112 DontRestoreProperties,
00113 RestoreProperties
00114 };
00115
00116 enum Error {
00117 NoError,
00118 NoInitialStateError,
00119 NoDefaultStateInHistoryStateError,
00120 NoCommonAncestorForTransitionError
00121 };
00122
00123 QStateMachine(QObject *parent = 0);
00124 ~QStateMachine();
00125
00126 void addState(QAbstractState *state);
00127 void removeState(QAbstractState *state);
00128
00129 Error error() const;
00130 QString errorString() const;
00131 void clearError();
00132
00133 bool isRunning() const;
00134
00135 #ifndef QT_NO_ANIMATION
00136 bool isAnimated() const;
00137 void setAnimated(bool enabled);
00138
00139 void addDefaultAnimation(QAbstractAnimation *animation);
00140 QList<QAbstractAnimation *> defaultAnimations() const;
00141 void removeDefaultAnimation(QAbstractAnimation *animation);
00142 #endif // QT_NO_ANIMATION
00143
00144 QStateMachine::RestorePolicy globalRestorePolicy() const;
00145 void setGlobalRestorePolicy(QStateMachine::RestorePolicy restorePolicy);
00146
00147 void postEvent(QEvent *event, EventPriority priority = NormalPriority);
00148 int postDelayedEvent(QEvent *event, int delay);
00149 bool cancelDelayedEvent(int id);
00150
00151 QSet<QAbstractState*> configuration() const;
00152
00153 #ifndef QT_NO_STATEMACHINE_EVENTFILTER
00154 bool eventFilter(QObject *watched, QEvent *event);
00155 #endif
00156
00157 public Q_SLOTS:
00158 void start();
00159 void stop();
00160
00161 Q_SIGNALS:
00162 void started();
00163 void stopped();
00164
00165 protected:
00166 void onEntry(QEvent *event);
00167 void onExit(QEvent *event);
00168
00169 virtual void beginSelectTransitions(QEvent *event);
00170 virtual void endSelectTransitions(QEvent *event);
00171
00172 virtual void beginMicrostep(QEvent *event);
00173 virtual void endMicrostep(QEvent *event);
00174
00175 bool event(QEvent *e);
00176
00177 protected:
00178 QStateMachine(QStateMachinePrivate &dd, QObject *parent);
00179
00180 private:
00181 Q_DISABLE_COPY(QStateMachine)
00182 Q_DECLARE_PRIVATE(QStateMachine)
00183 Q_PRIVATE_SLOT(d_func(), void _q_start())
00184 Q_PRIVATE_SLOT(d_func(), void _q_process())
00185 #ifndef QT_NO_ANIMATION
00186 Q_PRIVATE_SLOT(d_func(), void _q_animationFinished())
00187 #endif
00188 };
00189
00190 #endif //QT_NO_STATEMACHINE
00191
00192 QT_END_NAMESPACE
00193
00194 QT_END_HEADER
00195
00196 #endif