/**************************************************************************** ** ** Copyright (C) 2014 Ford Motor Company ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "statebase.h" #include #include #include StateBase::StateBase(QState *parent) : QState(parent) { } void StateBase::componentComplete() { if (this->machine() == NULL) { static bool once = false; if (!once) { once = true; qmlInfo(this) << "No top level StateMachine found. Nothing will run without a StateMachine."; } } } QQmlListProperty StateBase::children() { return QQmlListProperty(this, &m_children, m_children.append, m_children.count, m_children.at, m_children.clear); } /*! \qmltype QAbstractState \inqmlmodule QtStateMachine 1.0 \ingroup qmlstatemachine \since 5.4 \brief The QAbstractState type is the base type of States of a StateMachine. Do not use QAbstractState directly; use StateBase, FinalState or StateMachine instead. \sa StateMachine, StateBase */ /*! \qmlproperty bool QAbstractState::active \readonly active The active property of this state. A state is active between entered() and exited() signals. This property is readonly. \sa entered, exited */ /*! \qmlsignal QAbstractState::entered() This signal is emitted when the State becomes active. The corresponding handler is \c onEntered. \sa active, exited */ /*! \qmlsignal QAbstractState::exited() This signal is emitted when the State becomes inactive. The corresponding handler is \c onExited. \sa active, entered */ /*! \qmltype StateBase \inqmlmodule QtStateMachine 1.0 \inherits QAbstractState \ingroup qmlstatemachine \since 5.4 \brief Provides a general-purpose state for StateMachine. StateBase objects can have child states as well as transitions to other states. StateBase is part of \l{The Declarative State Machine Framework}. \section1 States with Child States The childMode property determines how child states are treated. For non-parallel state groups, the initialState property must be used to set the initial state. The child states are mutually exclusive states, and the state machine needs to know which child state to enter when the parent state is the target of a transition. The state emits the StateBase::finished() signal when a final child state (FinalState) is entered. The errorState sets the state's error state. The error state is the state that the state machine will transition to if an error is detected when attempting to enter the state (e.g. because no initial state has been set). \section1 Example Usage \snippet qml/statemachine/basicstate.qml document \clearfloat \sa StateMachine, FinalState */ /*! \qmlproperty enumeration StateBase::childMode \brief The child mode of this state The default value of this property is QState.ExclusiveStates. This enum specifies how a state's child states are treated: \list \li QState.ExclusiveStates The child states are mutually exclusive and an initial state must be set by setting initialState property. \li QState.ParallelStates The child states are parallel. When the parent state is entered, all its child states are entered in parallel. \endlist */ /*! \qmlproperty QAbstractState StateBase::errorState \brief The error state of this state. */ /*! \qmlproperty QAbstractState StateBase::initialState \brief The initial state of this state (one of its child states). */ /*! \qmlsignal StateBase::finished() This signal is emitted when a final child state of this state is entered. The corresponding handler is \c onFinished. \sa QAbstractState::active, QAbstractState::entered, QAbstractState::exited */ /*! \qmltype HistoryState \inqmlmodule QtStateMachine 1.0 \inherits QAbstractState \ingroup qmlstatemachine \since 5.4 \brief The HistoryState type provides a means of returning to a previously active substate. A history state is a pseudo-state that represents the child state that the parent state was in the last time the parent state was exited. A transition with a history state as its target is in fact a transition to one of the other child states of the parent state. HistoryState is part of \l{The Declarative State Machine Framework}. Use the defaultState property to set the state that should be entered if the parent state has never been entered. \section1 Example Usage \snippet qml/statemachine/historystate.qml document \clearfloat By default, a history state is shallow, meaning that it will not remember nested states. This can be configured through the historyType property. \sa StateMachine, StateBase */ /*! \qmlproperty QAbstractState HistoryState::defaultState \brief The default state of this history state. The default state indicates the state to transition to if the parent state has never been entered before. */ /*! \qmlproperty enumeration HistoryState::historyType \brief The type of history that this history state records. The default value of this property is QHistoryState.ShallowHistory. This enum specifies the type of history that a QHistoryState records. \list \li QHistoryState.ShallowHistory Only the immediate child states of the parent state are recorded. In this case, a transition with the history state as its target will end up in the immediate child state that the parent was in the last time it was exited. This is the default. \li QHistoryState.DeepHistory Nested states are recorded. In this case a transition with the history state as its target will end up in the most deeply nested descendant state the parent was in the last time it was exited. \endlist */