summaryrefslogtreecommitdiffstats
path: root/src/corelib/statemachine/qabstracttransition.h
blob: 4cf7faec5e2ff328725c74daa9f2b7a4fe6b018d (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
/****************************************************************************
**
** 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 QABSTRACTTRANSITION_H
#define QABSTRACTTRANSITION_H

#include <QtCore/qobject.h>

QT_BEGIN_HEADER

QT_BEGIN_NAMESPACE

QT_MODULE(Core)

class QEvent;
class QAbstractState;
class QState;

class QAbstractTransitionPrivate;
class Q_CORE_EXPORT QAbstractTransition : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QState* source READ sourceState)
    Q_PROPERTY(QAbstractState* target READ targetState WRITE setTargetState)
    Q_PROPERTY(QList<QAbstractState*> targets READ targetStates WRITE setTargetStates)
public:
    QAbstractTransition(QState *sourceState = 0);
    QAbstractTransition(const QList<QAbstractState*> &targets, QState *sourceState = 0);
    virtual ~QAbstractTransition();

    QState *sourceState() const;
    QAbstractState *targetState() const;
    void setTargetState(QAbstractState* target);
    QList<QAbstractState*> targetStates() const;
    void setTargetStates(const QList<QAbstractState*> &targets);

protected:
    virtual bool eventTest(QEvent *event) const = 0;

    virtual void onTransition() = 0;

    bool event(QEvent *e);

protected:
#ifdef QT_STATEMACHINE_SOLUTION
    QAbstractTransitionPrivate *d_ptr;
#endif
    QAbstractTransition(QAbstractTransitionPrivate &dd, QState *parent);
    QAbstractTransition(QAbstractTransitionPrivate &dd,
                        const QList<QAbstractState*> &targets, QState *parent);

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

QT_END_NAMESPACE

QT_END_HEADER

#endif