1// Copyright (C) 2016 Ford Motor Company
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "finalstate_p.h"
5
6#include <QQmlContext>
7#include <QQmlEngine>
8#include <QQmlInfo>
9
10FinalState::FinalState(QState *parent)
11 : QFinalState(parent)
12{
13}
14
15QQmlListProperty<QObject> FinalState::childrenActualCalculation() const
16{
17 // Mutating accesses to m_children only happen in the QML thread,
18 // so there are no thread-safety issues.
19 // The engine only creates non-const instances of the class anyway
20 return QQmlListProperty<QObject>(const_cast<FinalState*>(this), &m_children,
21 m_children.append, m_children.count, m_children.at,
22 m_children.clear, m_children.replace, m_children.removeLast);
23}
24
25QQmlListProperty<QObject> FinalState::children()
26{
27 return m_childrenComputedProperty;
28}
29
30void FinalState::childrenContentChanged()
31{
32 m_childrenComputedProperty.notify();
33 emit childrenChanged();
34}
35
36QBindable<QQmlListProperty<QObject>> FinalState::bindableChildren() const
37{
38 return &m_childrenComputedProperty;
39}
40
41/*!
42 \qmltype FinalState
43 \inqmlmodule QtQml.StateMachine
44 \inherits QAbstractState
45 \ingroup statemachine-qmltypes
46 \since 5.4
47
48 \brief Provides a final state.
49
50
51 A final state is used to communicate that (part of) a StateMachine has
52 finished its work. When a final top-level state is entered, the state
53 machine's \l{State::finished}{finished}() signal is emitted. In
54 general, when a final substate (a child of a State) is entered, the parent
55 state's \l{State::finished}{finished}() signal is emitted. FinalState
56 is part of \l{Qt State Machine QML Guide}{Qt State Machine QML API}
57
58 To use a final state, you create a FinalState object and add a transition
59 to it from another state.
60
61 \section1 Example Usage
62
63 \snippet qml/statemachine/finalstate.qml document
64
65 \clearfloat
66
67 \sa StateMachine, State
68*/
69

source code of qtscxml/src/statemachineqml/finalstate.cpp