1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QHISTORYSTATE_H
5#define QHISTORYSTATE_H
6
7#include <QtStateMachine/qabstractstate.h>
8
9QT_REQUIRE_CONFIG(statemachine);
10
11QT_BEGIN_NAMESPACE
12
13class QAbstractTransition;
14class QHistoryStatePrivate;
15class Q_STATEMACHINE_EXPORT QHistoryState : public QAbstractState
16{
17 Q_OBJECT
18 Q_PROPERTY(QAbstractState* defaultState READ defaultState WRITE setDefaultState NOTIFY defaultStateChanged)
19 Q_PROPERTY(QAbstractTransition* defaultTransition READ defaultTransition
20 WRITE setDefaultTransition NOTIFY defaultTransitionChanged
21 BINDABLE bindableDefaultTransition)
22 Q_PROPERTY(HistoryType historyType READ historyType WRITE setHistoryType
23 NOTIFY historyTypeChanged BINDABLE bindableHistoryType)
24public:
25 enum HistoryType {
26 ShallowHistory,
27 DeepHistory
28 };
29 Q_ENUM(HistoryType)
30
31 QHistoryState(QState *parent = nullptr);
32 QHistoryState(HistoryType type, QState *parent = nullptr);
33 ~QHistoryState();
34
35 QAbstractTransition *defaultTransition() const;
36 void setDefaultTransition(QAbstractTransition *transition);
37 QBindable<QAbstractTransition*> bindableDefaultTransition();
38
39 QAbstractState *defaultState() const;
40 void setDefaultState(QAbstractState *state);
41
42 HistoryType historyType() const;
43 void setHistoryType(HistoryType type);
44 QBindable<QHistoryState::HistoryType> bindableHistoryType();
45
46Q_SIGNALS:
47 void defaultTransitionChanged(QPrivateSignal);
48 void defaultStateChanged(QPrivateSignal);
49 void historyTypeChanged(QPrivateSignal);
50
51protected:
52 void onEntry(QEvent *event) override;
53 void onExit(QEvent *event) override;
54
55 bool event(QEvent *e) override;
56
57private:
58 Q_DISABLE_COPY(QHistoryState)
59 Q_DECLARE_PRIVATE(QHistoryState)
60};
61
62QT_END_NAMESPACE
63
64#endif
65

source code of qtscxml/src/statemachine/qhistorystate.h