summaryrefslogtreecommitdiffstats
path: root/src/corelib/statemachine/qstate.h
blob: ba2d034dafaccbabedf1157877608e07fedc092b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
** $TROLLTECH_DUAL_LICENSE$
**
****************************************************************************/

#ifndef QSTATE_H
#define QSTATE_H

#ifndef QT_STATEMACHINE_SOLUTION
#include <QtCore/qactionstate.h>
#else
#include "qactionstate.h"
#endif

QT_BEGIN_HEADER

QT_BEGIN_NAMESPACE

QT_MODULE(Core)

class QAbstractTransition;
class QHistoryState;
#ifndef QT_NO_ANIMATION
class QAbstractAnimation;
class QAnimationState;
#endif

class QStatePrivate;
class Q_CORE_EXPORT QState : public QActionState
{
    Q_OBJECT
public:
    enum Type {
        Normal,
        ParallelGroup
    };

    enum HistoryType {
        ShallowHistory,
        DeepHistory
    };

    QState(QState *parent = 0);
    QState(Type type, QState *parent = 0);
    ~QState();

    QAbstractState *errorState() const;
    void setErrorState(QAbstractState *state);

    void addTransition(QAbstractTransition *transition);
    void addTransition(QObject *sender, const char *signal, QAbstractState *target);
    void addTransition(QAbstractState *target);
    void addFinishedTransition(QAbstractState *target);
    void removeTransition(QAbstractTransition *transition);
    QList<QAbstractTransition*> transitions() const;

#ifndef QT_NO_ANIMATION
    QAnimationState *addAnimatedTransition(QObject *sender, const char *signal, 
                                           QAbstractState *targetState, 
                                           QAbstractAnimation *animation = 0);
    QAnimationState *addAnimatedTransition(QAbstractTransition *transition,
                                           QAbstractAnimation *animation = 0);
#endif

    QHistoryState *addHistoryState(HistoryType type = ShallowHistory);

    QAbstractState *initialState() const;
    void setInitialState(QAbstractState *state);

protected:
    void onEntry();
    void onExit();

    bool event(QEvent *e);

protected:
    QState(QStatePrivate &dd, QState *parent);

private:
    Q_DISABLE_COPY(QState)
    Q_DECLARE_PRIVATE(QState)
};

QT_END_NAMESPACE

QT_END_HEADER

#endif