aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Funk <kevin.funk@kdab.com>2014-10-09 16:05:33 +0200
committerBrett Stottlemyer <bstottle@ford.com>2014-10-21 02:13:33 +0200
commitf830c109d09d835551c1325c4904fc9a490b3754 (patch)
tree6bb3c09cb44ed0a5446749701ac4281831a62967
parent5871f3e829f1f48995b5d6c03f7ad31fcda386e5 (diff)
qmlstatemachine: Rename StateBase to State
As discussed with Brett Stottlmyer and Alan Alpert. Add a section about the implications when importing both QtQml.StateMachine and QtQuick in one single QML file. Change-Id: I8755f4b578e2a6ff4c2377c7a8a0b996ba9b7129 Reviewed-by: BogDan Vatra <bogdan@kde.org> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--src/imports/statemachine/finalstate.cpp6
-rw-r--r--src/imports/statemachine/plugin.cpp8
-rw-r--r--src/imports/statemachine/plugins.qmltypes6
-rw-r--r--src/imports/statemachine/state.cpp (renamed from src/imports/statemachine/statebase.cpp)30
-rw-r--r--src/imports/statemachine/state.h (renamed from src/imports/statemachine/statebase.h)6
-rw-r--r--src/imports/statemachine/statemachine.cpp16
-rw-r--r--src/imports/statemachine/statemachine.pro4
-rw-r--r--src/qml/doc/snippets/qml/statemachine/basicstate.qml6
-rw-r--r--src/qml/doc/snippets/qml/statemachine/finalstate.qml10
-rw-r--r--src/qml/doc/snippets/qml/statemachine/guardcondition.qml11
-rw-r--r--src/qml/doc/snippets/qml/statemachine/historystate.qml14
-rw-r--r--src/qml/doc/snippets/qml/statemachine/signaltransition.qml10
-rw-r--r--src/qml/doc/snippets/qml/statemachine/signaltransitionsignal.qml10
-rw-r--r--src/qml/doc/snippets/qml/statemachine/simplestatemachine.qml10
-rw-r--r--src/qml/doc/snippets/qml/statemachine/statemachine-button-history.qml12
-rw-r--r--src/qml/doc/snippets/qml/statemachine/statemachine-button-nested-ignore-quit.qml10
-rw-r--r--src/qml/doc/snippets/qml/statemachine/statemachine-button-nested.qml10
-rw-r--r--src/qml/doc/snippets/qml/statemachine/statemachine-button.qml8
-rw-r--r--src/qml/doc/snippets/qml/statemachine/timeouttransition.qml10
-rw-r--r--src/qml/doc/src/statemachine.qdoc52
-rw-r--r--tests/auto/qmltest/statemachine/tst_anonymousstate.qml4
-rw-r--r--tests/auto/qmltest/statemachine/tst_guardcondition.qml4
-rw-r--r--tests/auto/qmltest/statemachine/tst_historystate.qml8
-rw-r--r--tests/auto/qmltest/statemachine/tst_initialstate.qml4
-rw-r--r--tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml8
-rw-r--r--tests/auto/qmltest/statemachine/tst_nestedstatemachine.qml8
-rw-r--r--tests/auto/qmltest/statemachine/tst_parallelmachine.qml18
-rw-r--r--tests/auto/qmltest/statemachine/tst_trafficlight.qml14
28 files changed, 174 insertions, 143 deletions
diff --git a/src/imports/statemachine/finalstate.cpp b/src/imports/statemachine/finalstate.cpp
index 73e85a1abd..9b3c05e294 100644
--- a/src/imports/statemachine/finalstate.cpp
+++ b/src/imports/statemachine/finalstate.cpp
@@ -59,9 +59,9 @@ QQmlListProperty<QObject> FinalState::children()
A final state is used to communicate that (part of) a StateMachine has
finished its work. When a final top-level state is entered, the state
- machine's \l{StateBase::finished}{finished}() signal is emitted. In
+ machine's \l{State::finished}{finished}() signal is emitted. In
general, when a final substate (a child of a State) is entered, the parent
- state's \l{StateBase::finished}{finished}() signal is emitted. FinalState
+ state's \l{State::finished}{finished}() signal is emitted. FinalState
is part of \l{The Declarative State Machine Framework}.
To use a final state, you create a FinalState object and add a transition
@@ -73,5 +73,5 @@ QQmlListProperty<QObject> FinalState::children()
\clearfloat
- \sa StateMachine, StateBase
+ \sa StateMachine, State
*/
diff --git a/src/imports/statemachine/plugin.cpp b/src/imports/statemachine/plugin.cpp
index 678a4de199..a1ebe06a80 100644
--- a/src/imports/statemachine/plugin.cpp
+++ b/src/imports/statemachine/plugin.cpp
@@ -33,7 +33,7 @@
#include "finalstate.h"
#include "signaltransition.h"
-#include "statebase.h"
+#include "state.h"
#include "statemachine.h"
#include "timeouttransition.h"
@@ -51,12 +51,12 @@ class QtQmlStateMachinePlugin : public QQmlExtensionPlugin
public:
void registerTypes(const char *uri)
{
- qmlRegisterType<StateBase>(uri, 1, 0, "StateBase");
+ qmlRegisterType<State>(uri, 1, 0, "State");
qmlRegisterType<StateMachine>(uri, 1, 0, "StateMachine");
qmlRegisterType<QHistoryState>(uri, 1, 0, "HistoryState");
qmlRegisterType<FinalState>(uri, 1, 0, "FinalState");
- qmlRegisterUncreatableType<QState>(uri, 1, 0, "QState", "Don't use this, use StateBase instead");
- qmlRegisterUncreatableType<QAbstractState>(uri, 1, 0, "QAbstractState", "Don't use this, use StateBase instead");
+ qmlRegisterUncreatableType<QState>(uri, 1, 0, "QState", "Don't use this, use State instead");
+ qmlRegisterUncreatableType<QAbstractState>(uri, 1, 0, "QAbstractState", "Don't use this, use State instead");
qmlRegisterUncreatableType<QSignalTransition>(uri, 1, 0, "QSignalTransition", "Don't use this, use SignalTransition instead");
qmlRegisterType<SignalTransition>(uri, 1, 0, "SignalTransition");
qmlRegisterType<TimeoutTransition>(uri, 1, 0, "TimeoutTransition");
diff --git a/src/imports/statemachine/plugins.qmltypes b/src/imports/statemachine/plugins.qmltypes
index a53d68f8e8..db5897bb0f 100644
--- a/src/imports/statemachine/plugins.qmltypes
+++ b/src/imports/statemachine/plugins.qmltypes
@@ -130,16 +130,16 @@ Module {
exports: ["QtQml.StateMachine/SignalTransition 1.0"]
exportMetaObjectRevisions: [0]
Property { name: "signal"; type: "QJSValue" }
- Property { name: "guard"; type: "bool" }
+ Property { name: "guard"; type: "QQmlScriptString" }
Signal { name: "invokeYourself" }
Signal { name: "qmlSignalChanged" }
Method { name: "invoke" }
}
Component {
- name: "StateBase"
+ name: "State"
defaultProperty: "children"
prototype: "QState"
- exports: ["QtQml.StateMachine/StateBase 1.0"]
+ exports: ["QtQml.StateMachine/State 1.0"]
exportMetaObjectRevisions: [0]
Property { name: "children"; type: "QObject"; isList: true; isReadonly: true }
}
diff --git a/src/imports/statemachine/statebase.cpp b/src/imports/statemachine/state.cpp
index d33e294369..56ecd015f5 100644
--- a/src/imports/statemachine/statebase.cpp
+++ b/src/imports/statemachine/state.cpp
@@ -31,18 +31,18 @@
**
****************************************************************************/
-#include "statebase.h"
+#include "state.h"
#include <QQmlContext>
#include <QQmlEngine>
#include <QQmlInfo>
-StateBase::StateBase(QState *parent)
+State::State(QState *parent)
: QState(parent)
{
}
-void StateBase::componentComplete()
+void State::componentComplete()
{
if (this->machine() == NULL) {
static bool once = false;
@@ -53,7 +53,7 @@ void StateBase::componentComplete()
}
}
-QQmlListProperty<QObject> StateBase::children()
+QQmlListProperty<QObject> State::children()
{
return QQmlListProperty<QObject>(this, &m_children, m_children.append, m_children.count, m_children.at, m_children.clear);
}
@@ -68,10 +68,10 @@ QQmlListProperty<QObject> StateBase::children()
\brief The QAbstractState type is the base type of States of a StateMachine.
- Do not use QAbstractState directly; use StateBase, FinalState or
+ Do not use QAbstractState directly; use State, FinalState or
StateMachine instead.
- \sa StateMachine, StateBase
+ \sa StateMachine, State
*/
/*!
@@ -105,7 +105,7 @@ QQmlListProperty<QObject> StateBase::children()
*/
/*!
- \qmltype StateBase
+ \qmltype State
\inqmlmodule QtQml.StateMachine
\inherits QAbstractState
\ingroup statemachine-qmltypes
@@ -114,8 +114,8 @@ QQmlListProperty<QObject> StateBase::children()
\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}.
+ State objects can have child states as well as transitions to other
+ states. State is part of \l{The Declarative State Machine Framework}.
\section1 States with Child States
@@ -125,7 +125,7 @@ QQmlListProperty<QObject> StateBase::children()
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
+ The state emits the State::finished() signal when a final child state
(FinalState) is entered.
The errorState sets the state's error state. The error state is the state
@@ -142,7 +142,7 @@ QQmlListProperty<QObject> StateBase::children()
*/
/*!
- \qmlproperty enumeration StateBase::childMode
+ \qmlproperty enumeration State::childMode
\brief The child mode of this state
@@ -156,19 +156,19 @@ QQmlListProperty<QObject> StateBase::children()
*/
/*!
- \qmlproperty QAbstractState StateBase::errorState
+ \qmlproperty QAbstractState State::errorState
\brief The error state of this state.
*/
/*!
- \qmlproperty QAbstractState StateBase::initialState
+ \qmlproperty QAbstractState State::initialState
\brief The initial state of this state (one of its child states).
*/
/*!
- \qmlsignal StateBase::finished()
+ \qmlsignal State::finished()
This signal is emitted when a final child state of this state is entered.
@@ -204,7 +204,7 @@ QQmlListProperty<QObject> StateBase::children()
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
+ \sa StateMachine, State
*/
/*!
diff --git a/src/imports/statemachine/statebase.h b/src/imports/statemachine/state.h
index 38fb8f6d57..af8783e90d 100644
--- a/src/imports/statemachine/statebase.h
+++ b/src/imports/statemachine/state.h
@@ -42,7 +42,7 @@
QT_BEGIN_NAMESPACE
-class StateBase : public QState, public QQmlParserStatus
+class State : public QState, public QQmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
@@ -50,7 +50,7 @@ class StateBase : public QState, public QQmlParserStatus
Q_CLASSINFO("DefaultProperty", "children")
public:
- explicit StateBase(QState *parent = 0);
+ explicit State(QState *parent = 0);
void classBegin() {}
void componentComplete();
@@ -61,7 +61,7 @@ Q_SIGNALS:
void childrenChanged();
private:
- ChildrenPrivate<StateBase> m_children;
+ ChildrenPrivate<State> m_children;
};
QT_END_NAMESPACE
diff --git a/src/imports/statemachine/statemachine.cpp b/src/imports/statemachine/statemachine.cpp
index c65901a175..7b9ebdb88b 100644
--- a/src/imports/statemachine/statemachine.cpp
+++ b/src/imports/statemachine/statemachine.cpp
@@ -80,7 +80,7 @@ QQmlListProperty<QObject> StateMachine::children()
/*!
\qmltype StateMachine
\inqmlmodule QtQml.StateMachine
- \inherits StateBase
+ \inherits State
\ingroup statemachine-qmltypes
\since 5.4
@@ -97,7 +97,7 @@ QQmlListProperty<QObject> StateMachine::children()
algorithm. The framework's \l{The Declarative State Machine Framework}{overview}
gives several state graphs and the code to build them.
- Before the machine can be started, the \l{StateBase::initialState}{initialState}
+ Before the machine can be started, the \l{State::initialState}{initialState}
must be set. The initial state is the state that the
machine enters when started. You can then set running property to true
or start() the state machine. The started signal is emitted when the
@@ -116,7 +116,7 @@ QQmlListProperty<QObject> StateMachine::children()
\snippet qml/statemachine/simplestatemachine.qml document
If an error is encountered, the machine will look for an
- \l{StateBase::errorState}{errorState}, and if one is available, it will
+ \l{State::errorState}{errorState}, and if one is available, it will
enter this state. After the error state is entered, the type of the error
can be retrieved with error(). The execution of the state graph will not
stop when the error state is entered. If no error state applies to the
@@ -125,7 +125,7 @@ QQmlListProperty<QObject> StateMachine::children()
\clearfloat
- \sa QAbstractState, StateBase, SignalTransition, TimeoutTransition, HistoryState {The Declarative State Machine Framework}
+ \sa QAbstractState, State, SignalTransition, TimeoutTransition, HistoryState {The Declarative State Machine Framework}
*/
/*!
@@ -181,18 +181,18 @@ QQmlListProperty<QObject> StateMachine::children()
the main application event loop started with QCoreApplication::exec() or
QApplication::exec().
- \sa started, StateBase::finished, stop(), StateBase::initialState, running
+ \sa started, State::finished, stop(), State::initialState, running
*/
/*!
\qmlsignal StateMachine::started()
This signal is emitted when the state machine has entered its initial state
- (StateBase::initialState).
+ (State::initialState).
The corresponding handler is \c onStarted.
- \sa running, start(), StateBase::finished
+ \sa running, start(), State::finished
*/
/*!
@@ -211,5 +211,5 @@ QQmlListProperty<QObject> StateMachine::children()
The corresponding handler is \c onStopped.
- \sa running, stop(), StateBase::finished
+ \sa running, stop(), State::finished
*/
diff --git a/src/imports/statemachine/statemachine.pro b/src/imports/statemachine/statemachine.pro
index 4cc7089a32..9bb88074e9 100644
--- a/src/imports/statemachine/statemachine.pro
+++ b/src/imports/statemachine/statemachine.pro
@@ -8,7 +8,7 @@ QT = core-private qml-private
SOURCES = \
$$PWD/finalstate.cpp \
$$PWD/signaltransition.cpp \
- $$PWD/statebase.cpp \
+ $$PWD/state.cpp \
$$PWD/statemachine.cpp \
$$PWD/timeouttransition.cpp \
$$PWD/plugin.cpp
@@ -17,7 +17,7 @@ HEADERS = \
$$PWD/childrenprivate.h \
$$PWD/finalstate.h \
$$PWD/signaltransition.h \
- $$PWD/statebase.h \
+ $$PWD/state.h \
$$PWD/statemachine.h \
$$PWD/timeouttransition.h
diff --git a/src/qml/doc/snippets/qml/statemachine/basicstate.qml b/src/qml/doc/snippets/qml/statemachine/basicstate.qml
index dd9d100e9d..ccdd2b2ec1 100644
--- a/src/qml/doc/snippets/qml/statemachine/basicstate.qml
+++ b/src/qml/doc/snippets/qml/statemachine/basicstate.qml
@@ -39,15 +39,15 @@
****************************************************************************/
//! [document]
-import QtQml.StateMachine 1.0
import QtQuick 2.0
+import QtQml.StateMachine 1.0 as DSM
Rectangle {
- StateMachine {
+ DSM.StateMachine {
id: stateMachine
initialState: state
running: true
- StateBase {
+ DSM.State {
id: state
}
}
diff --git a/src/qml/doc/snippets/qml/statemachine/finalstate.qml b/src/qml/doc/snippets/qml/statemachine/finalstate.qml
index d03a4bce40..5865436a52 100644
--- a/src/qml/doc/snippets/qml/statemachine/finalstate.qml
+++ b/src/qml/doc/snippets/qml/statemachine/finalstate.qml
@@ -39,22 +39,22 @@
****************************************************************************/
//! [document]
-import QtQml.StateMachine 1.0
import QtQuick 2.0
+import QtQml.StateMachine 1.0 as DSM
Rectangle {
- StateMachine {
+ DSM.StateMachine {
id: stateMachine
initialState: state
running: true
- StateBase {
+ DSM.State {
id: state
- TimeoutTransition {
+ DSM.TimeoutTransition {
targetState: finalState
timeout: 200
}
}
- FinalState {
+ DSM.FinalState {
id: finalState
}
onFinished: console.log("state finished")
diff --git a/src/qml/doc/snippets/qml/statemachine/guardcondition.qml b/src/qml/doc/snippets/qml/statemachine/guardcondition.qml
index f9ecf450bd..3d4badb350 100644
--- a/src/qml/doc/snippets/qml/statemachine/guardcondition.qml
+++ b/src/qml/doc/snippets/qml/statemachine/guardcondition.qml
@@ -39,23 +39,23 @@
****************************************************************************/
//! [document]
-import QtQml.StateMachine 1.0
import QtQuick 2.0
+import QtQml.StateMachine 1.0 as DSM
Rectangle {
Button {
anchors.fill: parent
id: button
- StateMachine {
- StateBase {
- SignalTransition {
+ DSM.StateMachine {
+ DSM.State {
+ DSM.SignalTransition {
targetState: finalState
signal: button.mysignal
// the guard condition uses the mystr string argument from mysignal
guard: mystr == "test"
}
}
- FinalState {
+ DSM.FinalState {
id: finalState
}
}
@@ -66,4 +66,3 @@ Rectangle {
}
}
//! [document]
-
diff --git a/src/qml/doc/snippets/qml/statemachine/historystate.qml b/src/qml/doc/snippets/qml/statemachine/historystate.qml
index 237cf57175..7559bfe06c 100644
--- a/src/qml/doc/snippets/qml/statemachine/historystate.qml
+++ b/src/qml/doc/snippets/qml/statemachine/historystate.qml
@@ -39,38 +39,38 @@
****************************************************************************/
//! [document]
-import QtQml.StateMachine 1.0
import QtQuick 2.0
+import QtQml.StateMachine 1.0 as DSM
Rectangle {
Button {
anchors.fill: parent
id: button
text: "Press me"
- StateMachine {
+ DSM.StateMachine {
id: stateMachine
initialState: parentState
running: true
- StateBase {
+ DSM.State {
id: parentState
initialState: child2
onEntered: console.log("parentState entered")
onExited: console.log("parentState exited")
- StateBase {
+ DSM.State {
id: child1
onEntered: console.log("child1 entered")
onExited: console.log("child1 exited")
}
- StateBase {
+ DSM.State {
id: child2
onEntered: console.log("child2 entered")
onExited: console.log("child2 exited")
}
- HistoryState {
+ DSM.HistoryState {
id: historyState
defaultState: child1
}
- SignalTransition {
+ DSM.SignalTransition {
targetState: historyState
// Clicking the button will cause the state machine to enter the child state
diff --git a/src/qml/doc/snippets/qml/statemachine/signaltransition.qml b/src/qml/doc/snippets/qml/statemachine/signaltransition.qml
index 7402ac089f..d00a103d7c 100644
--- a/src/qml/doc/snippets/qml/statemachine/signaltransition.qml
+++ b/src/qml/doc/snippets/qml/statemachine/signaltransition.qml
@@ -39,23 +39,23 @@
****************************************************************************/
//! [document]
-import QtQml.StateMachine 1.0
import QtQuick 2.0
+import QtQml.StateMachine 1.0 as DSM
Rectangle {
- StateMachine {
+ DSM.StateMachine {
id: stateMachine
initialState: state
running: true
- StateBase {
+ DSM.State {
id: state
- SignalTransition {
+ DSM.SignalTransition {
targetState: finalState
signal: button.clicked
guard: guardButton.checked
}
}
- FinalState {
+ DSM.FinalState {
id: finalState
}
onFinished: Qt.quit()
diff --git a/src/qml/doc/snippets/qml/statemachine/signaltransitionsignal.qml b/src/qml/doc/snippets/qml/statemachine/signaltransitionsignal.qml
index 44608fed36..90ebd70eb5 100644
--- a/src/qml/doc/snippets/qml/statemachine/signaltransitionsignal.qml
+++ b/src/qml/doc/snippets/qml/statemachine/signaltransitionsignal.qml
@@ -39,21 +39,21 @@
****************************************************************************/
//! [document]
-import QtQml.StateMachine 1.0
import QtQuick 2.0
+import QtQml.StateMachine 1.0 as DSM
Rectangle {
Button {
anchors.fill: parent
id: button
- StateMachine {
- StateBase {
- SignalTransition {
+ DSM.StateMachine {
+ DSM.State {
+ DSM.SignalTransition {
targetState: finalState
signal: button.clicked
}
}
- FinalState {
+ DSM.FinalState {
id: finalState
}
}
diff --git a/src/qml/doc/snippets/qml/statemachine/simplestatemachine.qml b/src/qml/doc/snippets/qml/statemachine/simplestatemachine.qml
index f5c6923cd1..4e5ea9b65c 100644
--- a/src/qml/doc/snippets/qml/statemachine/simplestatemachine.qml
+++ b/src/qml/doc/snippets/qml/statemachine/simplestatemachine.qml
@@ -39,26 +39,26 @@
****************************************************************************/
//! [document]
-import QtQml.StateMachine 1.0
import QtQuick 2.0
+import QtQml.StateMachine 1.0 as DSM
Rectangle {
Button {
anchors.fill: parent
id: button
text: "Finish state"
- StateMachine {
+ DSM.StateMachine {
id: stateMachine
initialState: state
running: true
- StateBase {
+ DSM.State {
id: state
- SignalTransition {
+ DSM.SignalTransition {
targetState: finalState
signal: button.clicked
}
}
- FinalState {
+ DSM.FinalState {
id: finalState
}
onFinished: Qt.quit()
diff --git a/src/qml/doc/snippets/qml/statemachine/statemachine-button-history.qml b/src/qml/doc/snippets/qml/statemachine/statemachine-button-history.qml
index 10595a9398..8f628232c1 100644
--- a/src/qml/doc/snippets/qml/statemachine/statemachine-button-history.qml
+++ b/src/qml/doc/snippets/qml/statemachine/statemachine-button-history.qml
@@ -39,8 +39,8 @@
****************************************************************************/
//! [document]
-import QtQml.StateMachine 1.0
import QtQuick 2.0
+import QtQml.StateMachine 1.0
Rectangle {
//![0]
@@ -71,7 +71,7 @@ Rectangle {
// start the state machine
running: true
- StateBase {
+ State {
id: s1
// set the initial state
initialState: s11
@@ -84,7 +84,7 @@ Rectangle {
// do something when the state enters/exits
onEntered: console.log("s1 entered")
onExited: console.log("s1 exited")
- StateBase {
+ State {
id: s11
// create a transition from s1 to s2 when the button is clicked
SignalTransition {
@@ -96,7 +96,7 @@ Rectangle {
onExited: console.log("s11 exited")
}
- StateBase {
+ State {
id: s12
// create a transition from s2 to s3 when the button is clicked
SignalTransition {
@@ -107,7 +107,7 @@ Rectangle {
onEntered: console.log("s12 entered")
onExited: console.log("s12 exited")
}
- StateBase {
+ State {
id: s13
// create a transition from s3 to s1 when the button is clicked
SignalTransition {
@@ -133,7 +133,7 @@ Rectangle {
onEntered: console.log("s2 entered")
onExited: console.log("s2 exited")
}
- StateBase {
+ State {
id: s3
SignalTransition {
targetState: s1h
diff --git a/src/qml/doc/snippets/qml/statemachine/statemachine-button-nested-ignore-quit.qml b/src/qml/doc/snippets/qml/statemachine/statemachine-button-nested-ignore-quit.qml
index 00f9cd3871..bf84b4cc90 100644
--- a/src/qml/doc/snippets/qml/statemachine/statemachine-button-nested-ignore-quit.qml
+++ b/src/qml/doc/snippets/qml/statemachine/statemachine-button-nested-ignore-quit.qml
@@ -39,8 +39,8 @@
****************************************************************************/
//! [document]
-import QtQml.StateMachine 1.0
import QtQuick 2.0
+import QtQml.StateMachine 1.0
Rectangle {
Row {
@@ -66,7 +66,7 @@ Rectangle {
// start the state machine
running: true
- StateBase {
+ State {
id: s1
// set the initial state
initialState: s11
@@ -79,7 +79,7 @@ Rectangle {
// do something when the state enters/exits
onEntered: console.log("s1 entered")
onExited: console.log("s1 exited")
- StateBase {
+ State {
id: s11
// create a transition from s11 to s12 when the button is clicked
SignalTransition {
@@ -92,7 +92,7 @@ Rectangle {
}
//![0]
- StateBase {
+ State {
id: s12
// create a transition from s12 to s13 when the button is clicked
SignalTransition {
@@ -112,7 +112,7 @@ Rectangle {
}
//![0]
- StateBase {
+ State {
id: s13
// create a transition from s13 to s11 when the button is clicked
SignalTransition {
diff --git a/src/qml/doc/snippets/qml/statemachine/statemachine-button-nested.qml b/src/qml/doc/snippets/qml/statemachine/statemachine-button-nested.qml
index 68bd57d85f..dfa093716f 100644
--- a/src/qml/doc/snippets/qml/statemachine/statemachine-button-nested.qml
+++ b/src/qml/doc/snippets/qml/statemachine/statemachine-button-nested.qml
@@ -39,8 +39,8 @@
****************************************************************************/
//! [document]
-import QtQml.StateMachine 1.0
import QtQuick 2.0
+import QtQml.StateMachine 1.0
Rectangle {
//![0]
@@ -67,7 +67,7 @@ Rectangle {
// start the state machine
running: true
- StateBase {
+ State {
id: s1
// set the initial state
initialState: s11
@@ -80,7 +80,7 @@ Rectangle {
// do something when the state enters/exits
onEntered: console.log("s1 entered")
onExited: console.log("s1 exited")
- StateBase {
+ State {
id: s11
// create a transition from s11 to s12 when the button is clicked
SignalTransition {
@@ -92,7 +92,7 @@ Rectangle {
onExited: console.log("s11 exited")
}
- StateBase {
+ State {
id: s12
// create a transition from s12 to s13 when the button is clicked
SignalTransition {
@@ -103,7 +103,7 @@ Rectangle {
onEntered: console.log("s12 entered")
onExited: console.log("s12 exited")
}
- StateBase {
+ State {
id: s13
// create a transition from s13 to s11 when the button is clicked
SignalTransition {
diff --git a/src/qml/doc/snippets/qml/statemachine/statemachine-button.qml b/src/qml/doc/snippets/qml/statemachine/statemachine-button.qml
index f2817ead8b..6c4ed846e5 100644
--- a/src/qml/doc/snippets/qml/statemachine/statemachine-button.qml
+++ b/src/qml/doc/snippets/qml/statemachine/statemachine-button.qml
@@ -39,8 +39,8 @@
****************************************************************************/
//! [document]
-import QtQml.StateMachine 1.0
import QtQuick 2.0
+import QtQml.StateMachine 1.0
Rectangle {
//![0]
@@ -60,7 +60,7 @@ Rectangle {
// start the state machine
running: true
- StateBase {
+ State {
id: s1
// create a transition from s1 to s2 when the button is clicked
SignalTransition {
@@ -72,7 +72,7 @@ Rectangle {
onExited: console.log("s1 exited")
}
- StateBase {
+ State {
id: s2
// create a transition from s2 to s3 when the button is clicked
SignalTransition {
@@ -83,7 +83,7 @@ Rectangle {
onEntered: console.log("s2 entered")
onExited: console.log("s2 exited")
}
- StateBase {
+ State {
id: s3
// create a transition from s3 to s1 when the button is clicked
SignalTransition {
diff --git a/src/qml/doc/snippets/qml/statemachine/timeouttransition.qml b/src/qml/doc/snippets/qml/statemachine/timeouttransition.qml
index b15c99cd22..7b8fa77b13 100644
--- a/src/qml/doc/snippets/qml/statemachine/timeouttransition.qml
+++ b/src/qml/doc/snippets/qml/statemachine/timeouttransition.qml
@@ -39,8 +39,8 @@
****************************************************************************/
//! [document]
-import QtQml.StateMachine 1.0
import QtQuick 2.0
+import QtQml.StateMachine 1.0 as DSM
Rectangle {
Button {
@@ -49,18 +49,18 @@ Rectangle {
text: "Finish state"
enabled: !stateMachine.running
onClicked: stateMachine.running = true
- StateMachine {
+ DSM.StateMachine {
id: stateMachine
initialState: state
running: true
- StateBase {
+ DSM.State {
id: state
- TimeoutTransition {
+ DSM.TimeoutTransition {
targetState: finalState
timeout: 1000
}
}
- FinalState {
+ DSM.FinalState {
id: finalState
}
}
diff --git a/src/qml/doc/src/statemachine.qdoc b/src/qml/doc/src/statemachine.qdoc
index 68c57055ca..f200f6f3c0 100644
--- a/src/qml/doc/src/statemachine.qdoc
+++ b/src/qml/doc/src/statemachine.qdoc
@@ -61,7 +61,39 @@
\annotatedlist statemachine-qmltypes
- \section1 A Simple Example
+ \section1 Using both QtQuick and QtQml.StateMachine imports
+
+ \warning If you're attempting to import both \l{QtQuick} and
+ \e{QtQml.StateMachine} in one single QML file, make sure to import
+ \e{QtQml.StateMachine} \e{last}. This way, the \e{State} type is provided
+ by the Declarative State Machine Framework and not by \l{QtQuick}:
+
+ \qml
+ import QtQuick 2.0
+ import QtQml.StateMachine 1.0
+
+ StateMachine {
+ State {
+ // okay, is of type QtQml.StateMachine.State
+ }
+ }
+ \endqml
+
+ Alternatively, you can import \e{QtQml.StateMachine} into a separate
+ namespace to avoid any ambiguity with QtQuick's \e{State} item:
+
+ \qml
+ import QtQuick 2.0
+ import QtQml.StateMachine 1.0 as DSM
+
+ DSM.StateMachine {
+ DSM.State {
+ // ...
+ }
+ }
+ \endqml
+
+ \section1 A Simple State Machine
To demonstrate the core functionality of the State Machine API, let's look
at an example: A state machine with three states, \c s1, \c s2 and \c
@@ -84,7 +116,7 @@
The state machine defined in the previous section never finishes. In order
for a state machine to be able to finish, it needs to have a top-level \e
final state (FinalState object). When the state machine enters the top-level
- final state, the machine emits the \l{StateBase::finished}{finished}
+ final state, the machine emits the \l{State::finished}{finished}
signal and halts.
All you need to do to introduce a final state in the graph is create a
@@ -191,13 +223,13 @@
To create a parallel state group, set childMode to QState.ParallelStates.
\qml
- StateBase {
+ State {
id: s1
childMode: QState.ParallelStates
- StateBase {
+ State {
id: s11
}
- StateBase {
+ State {
id: s12
}
}
@@ -221,18 +253,18 @@
\section1 Exiting a Composite State
A child state can be final (a FinalState object); when a final child state
- is entered, the parent state emits the StateBase::finished signal. The
+ is entered, the parent state emits the State::finished signal. The
following diagram shows a composite state \c s1 which does some processing
before entering a final state:
\image statemachine-finished.png
When \c s1 's final state is entered, \c s1 will automatically emit
- \l{StateBase::finished}{finished}. We use a signal transition to cause this event to
+ \l{State::finished}{finished}. We use a signal transition to cause this event to
trigger a state change:
\qml
- StateBase {
+ State {
id: s1
SignalTransition {
targetState: s2
@@ -251,7 +283,7 @@
finished() signal, but with the consequence that implementation details of
\c s1 are exposed and depended on).
- For parallel state groups, the StateBase::finished signal is emitted when \e
+ For parallel state groups, the State::finished signal is emitted when \e
all the child states have entered final states.
\section1 Targetless Transitions
@@ -270,7 +302,7 @@
id: stateMachine
initialState: s1
running: true
- StateBase {
+ State {
id: s1
SignalTransition {
signal: button.clicked
diff --git a/tests/auto/qmltest/statemachine/tst_anonymousstate.qml b/tests/auto/qmltest/statemachine/tst_anonymousstate.qml
index cce5f8dcb7..b05d5c67a9 100644
--- a/tests/auto/qmltest/statemachine/tst_anonymousstate.qml
+++ b/tests/auto/qmltest/statemachine/tst_anonymousstate.qml
@@ -31,12 +31,12 @@
**
****************************************************************************/
-import QtQml.StateMachine 1.0
import QtTest 1.0
+import QtQml.StateMachine 1.0
TestCase {
StateMachine {
- StateBase {
+ State {
}
}
name: "anonymousState"
diff --git a/tests/auto/qmltest/statemachine/tst_guardcondition.qml b/tests/auto/qmltest/statemachine/tst_guardcondition.qml
index 71171b2079..0390b5f8fa 100644
--- a/tests/auto/qmltest/statemachine/tst_guardcondition.qml
+++ b/tests/auto/qmltest/statemachine/tst_guardcondition.qml
@@ -39,15 +39,15 @@
**
****************************************************************************/
-import QtQml.StateMachine 1.0
import QtTest 1.0
+import QtQml.StateMachine 1.0
TestCase {
id: testCase
StateMachine {
id: machine
initialState: startState
- StateBase {
+ State {
id: startState
SignalTransition {
id: signalTrans
diff --git a/tests/auto/qmltest/statemachine/tst_historystate.qml b/tests/auto/qmltest/statemachine/tst_historystate.qml
index f2fc110c24..6e2aa70417 100644
--- a/tests/auto/qmltest/statemachine/tst_historystate.qml
+++ b/tests/auto/qmltest/statemachine/tst_historystate.qml
@@ -31,8 +31,8 @@
**
****************************************************************************/
-import QtQml.StateMachine 1.0
import QtTest 1.0
+import QtQml.StateMachine 1.0
TestCase {
@@ -40,7 +40,7 @@ TestCase {
id: stateMachine
initialState: historyState1
- StateBase {
+ State {
id: state1
SignalTransition {
id: st1
@@ -48,14 +48,14 @@ TestCase {
}
}
- StateBase {
+ State {
id: state2
initialState: historyState2
HistoryState {
id: historyState2
defaultState: state21
}
- StateBase {
+ State {
id: state21
}
}
diff --git a/tests/auto/qmltest/statemachine/tst_initialstate.qml b/tests/auto/qmltest/statemachine/tst_initialstate.qml
index 6d5fbadf26..c08b3f7001 100644
--- a/tests/auto/qmltest/statemachine/tst_initialstate.qml
+++ b/tests/auto/qmltest/statemachine/tst_initialstate.qml
@@ -31,15 +31,15 @@
**
****************************************************************************/
-import QtQml.StateMachine 1.0
import QtTest 1.0
+import QtQml.StateMachine 1.0
TestCase {
StateMachine {
id: myStateMachine
initialState: myState;
running: true
- StateBase {
+ State {
id: myState
}
}
diff --git a/tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml b/tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml
index 2906de2986..443771f8f4 100644
--- a/tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml
+++ b/tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml
@@ -31,20 +31,20 @@
**
****************************************************************************/
-import QtQml.StateMachine 1.0
import QtTest 1.0
+import QtQml.StateMachine 1.0
TestCase {
StateMachine {
id: myStateMachine
initialState: parentState
- StateBase {
+ State {
id: parentState
initialState: childState1
- StateBase {
+ State {
id: childState1
}
- StateBase {
+ State {
id: childState2
}
}
diff --git a/tests/auto/qmltest/statemachine/tst_nestedstatemachine.qml b/tests/auto/qmltest/statemachine/tst_nestedstatemachine.qml
index 41a2c2a852..f584b7cd01 100644
--- a/tests/auto/qmltest/statemachine/tst_nestedstatemachine.qml
+++ b/tests/auto/qmltest/statemachine/tst_nestedstatemachine.qml
@@ -31,23 +31,23 @@
**
****************************************************************************/
-import QtQml.StateMachine 1.0
import QtTest 1.0
+import QtQml.StateMachine 1.0
TestCase {
StateMachine {
id: myStateMachine
initialState: parentState
- StateBase {
+ State {
id: parentState
initialState: childStateMachine
StateMachine {
id: childStateMachine
initialState: childState2
- StateBase {
+ State {
id: childState1
}
- StateBase {
+ State {
id: childState2
}
}
diff --git a/tests/auto/qmltest/statemachine/tst_parallelmachine.qml b/tests/auto/qmltest/statemachine/tst_parallelmachine.qml
index 0f35af0d99..2e3a5efdfd 100644
--- a/tests/auto/qmltest/statemachine/tst_parallelmachine.qml
+++ b/tests/auto/qmltest/statemachine/tst_parallelmachine.qml
@@ -31,30 +31,30 @@
**
****************************************************************************/
-import QtQml.StateMachine 1.0
import QtTest 1.0
+import QtQml.StateMachine 1.0
TestCase {
StateMachine {
id: myStateMachine
- childMode: StateBase.ParallelStates
- StateBase {
+ childMode: State.ParallelStates
+ State {
id: childState1
- childMode: StateBase.ParallelStates
- StateBase {
+ childMode: State.ParallelStates
+ State {
id: childState11
}
- StateBase {
+ State {
id: childState12
}
}
- StateBase {
+ State {
id: childState2
initialState: childState21
- StateBase {
+ State {
id: childState21
}
- StateBase {
+ State {
id: childState22
}
}
diff --git a/tests/auto/qmltest/statemachine/tst_trafficlight.qml b/tests/auto/qmltest/statemachine/tst_trafficlight.qml
index 8a7cad8268..3f731a4014 100644
--- a/tests/auto/qmltest/statemachine/tst_trafficlight.qml
+++ b/tests/auto/qmltest/statemachine/tst_trafficlight.qml
@@ -31,8 +31,8 @@
**
****************************************************************************/
-import QtQml.StateMachine 1.0
import QtTest 1.0
+import QtQml.StateMachine 1.0
TestCase {
StateMachine {
@@ -42,10 +42,10 @@ TestCase {
id: finalState
}
- StateBase {
+ State {
id: red
initialState: justRed
- StateBase {
+ State {
id: justRed
SignalTransition {
id: e1
@@ -56,7 +56,7 @@ TestCase {
targetState: finalState
}
}
- StateBase {
+ State {
id: waitingForGreen
TimeoutTransition {
id: e2
@@ -65,7 +65,7 @@ TestCase {
}
}
}
- StateBase {
+ State {
id: yellowred
TimeoutTransition {
id: e3
@@ -73,7 +73,7 @@ TestCase {
timeout: 10
}
}
- StateBase {
+ State {
id: green
TimeoutTransition {
id: e4
@@ -81,7 +81,7 @@ TestCase {
timeout: 50
}
}
- StateBase {
+ State {
id: yellow
TimeoutTransition {
id: e5