- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qstatemachine.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtCore module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    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