1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtCore module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qfinalstate_p.h"
41
42QT_BEGIN_NAMESPACE
43
44/*!
45 \class QFinalState
46 \inmodule QtCore
47
48 \brief The QFinalState class provides a final state.
49
50 \since 4.6
51 \ingroup statemachine
52
53 A final state is used to communicate that (part of) a QStateMachine has
54 finished its work. When a final top-level state is entered, the state
55 machine's \l{QStateMachine::finished()}{finished}() signal is emitted. In
56 general, when a final substate (a child of a QState) is entered, the parent
57 state's \l{QState::finished()}{finished}() signal is emitted. QFinalState
58 is part of \l{The State Machine Framework}.
59
60 To use a final state, you create a QFinalState object and add a transition
61 to it from another state. Example:
62
63 \code
64 QPushButton button;
65
66 QStateMachine machine;
67 QState *s1 = new QState();
68 QFinalState *s2 = new QFinalState();
69 s1->addTransition(&button, SIGNAL(clicked()), s2);
70 machine.addState(s1);
71 machine.addState(s2);
72
73 QObject::connect(&machine, SIGNAL(finished()), QApplication::instance(), SLOT(quit()));
74 machine.setInitialState(s1);
75 machine.start();
76 \endcode
77
78 \sa QState::finished()
79*/
80
81QFinalStatePrivate::QFinalStatePrivate()
82 : QAbstractStatePrivate(FinalState)
83{
84}
85
86QFinalStatePrivate::~QFinalStatePrivate()
87{
88 // to prevent vtables being generated in every file that includes the private header
89}
90
91/*!
92 Constructs a new QFinalState object with the given \a parent state.
93*/
94QFinalState::QFinalState(QState *parent)
95 : QAbstractState(*new QFinalStatePrivate, parent)
96{
97}
98
99/*!
100 \internal
101 */
102QFinalState::QFinalState(QFinalStatePrivate &dd, QState *parent)
103 : QAbstractState(dd, parent)
104{
105}
106
107
108/*!
109 Destroys this final state.
110*/
111QFinalState::~QFinalState()
112{
113}
114
115/*!
116 \reimp
117*/
118void QFinalState::onEntry(QEvent *event)
119{
120 Q_UNUSED(event);
121}
122
123/*!
124 \reimp
125*/
126void QFinalState::onExit(QEvent *event)
127{
128 Q_UNUSED(event);
129}
130
131/*!
132 \reimp
133*/
134bool QFinalState::event(QEvent *e)
135{
136 return QAbstractState::event(e);
137}
138
139QT_END_NAMESPACE
140
141#include "moc_qfinalstate.cpp"
142

source code of qtbase/src/corelib/statemachine/qfinalstate.cpp