diff options
author | Karsten Heimrich <karsten.heimrich@qt.io> | 2020-08-14 13:04:22 +0200 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@qt.io> | 2020-08-23 20:56:31 +0200 |
commit | ae36d94c2f385e272ae25fcd0fe780edb70cf7d9 (patch) | |
tree | 5812b2a57c9f355313755b95a09358f9c19cd7d4 | |
parent | 48b4c1f450109b148f03f62574d78b460859c4a1 (diff) |
Remove qml statemachine plugin from qtdeclarative
Task-number: QTBUG-80316
Change-Id: I584b699a1eec88117f343870bd2cd01075da64f7
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
64 files changed, 1 insertions, 4657 deletions
diff --git a/src/imports/CMakeLists.txt b/src/imports/CMakeLists.txt index 9970e5a39d..d2c8e5694f 100644 --- a/src/imports/CMakeLists.txt +++ b/src/imports/CMakeLists.txt @@ -16,9 +16,6 @@ endif() if(QT_FEATURE_settings) add_subdirectory(settings) endif() -if(QT_FEATURE_statemachine) - add_subdirectory(statemachine) -endif() if(TARGET Qt::Quick) add_subdirectory(labsanimation) add_subdirectory(layouts) diff --git a/src/imports/imports.pro b/src/imports/imports.pro index 0ea9395179..c97da5809f 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -11,7 +11,6 @@ qtConfig(qml-itemmodel): SUBDIRS += folderlistmodel qtConfig(qml-worker-script): SUBDIRS += workerscript qtHaveModule(sql): SUBDIRS += localstorage qtConfig(settings): SUBDIRS += settings -qtConfig(statemachine): SUBDIRS += statemachine qtHaveModule(quick) { QT_FOR_CONFIG += quick-private diff --git a/src/imports/statemachine/CMakeLists.txt b/src/imports/statemachine/CMakeLists.txt deleted file mode 100644 index 232f3f28d5..0000000000 --- a/src/imports/statemachine/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -# Generated from statemachine.pro. - -##################################################################### -## qtqmlstatemachine Plugin: -##################################################################### - -qt_add_qml_module(qtqmlstatemachine - URI "QtQml.StateMachine" - VERSION "${CMAKE_PROJECT_VERSION}" - CLASSNAME QtQmlStateMachinePlugin - SKIP_TYPE_REGISTRATION - GENERATE_QMLTYPES - SOURCES - childrenprivate.h - finalstate.cpp finalstate.h - plugin.cpp - signaltransition.cpp signaltransition.h - state.cpp state.h - statemachine.cpp statemachine.h - statemachineforeign.h - timeouttransition.cpp timeouttransition.h - PUBLIC_LIBRARIES - Qt::CorePrivate - Qt::QmlPrivate -) - -#### Keys ignored in scope 1:.:.:statemachine.pro:<TRUE>: -# CXX_MODULE = "qml" -# QML_IMPORT_VERSION = "$$QT_VERSION" -# TARGETPATH = "QtQml/StateMachine" diff --git a/src/imports/statemachine/childrenprivate.h b/src/imports/statemachine/childrenprivate.h deleted file mode 100644 index 2dcecd6531..0000000000 --- a/src/imports/statemachine/childrenprivate.h +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQMLCHILDRENPRIVATE_H -#define QQMLCHILDRENPRIVATE_H - -#include <QAbstractState> -#include <QAbstractTransition> -#include <QStateMachine> -#include <QQmlInfo> -#include <QQmlListProperty> - -enum class ChildrenMode { - None = 0x0, - State = 0x1, - Transition = 0x2, - StateOrTransition = State | Transition -}; - -template<typename T> -static T *parentObject(QQmlListProperty<QObject> *prop) { return static_cast<T *>(prop->object); } - -template<class T, ChildrenMode Mode> -struct ParentHandler -{ - static bool unparentItem(QQmlListProperty<QObject> *prop, QObject *oldItem); - static bool parentItem(QQmlListProperty<QObject> *prop, QObject *item); -}; - -template<class T> -struct ParentHandler<T, ChildrenMode::None> -{ - static bool unparentItem(QQmlListProperty<QObject> *, QObject *) { return true; } - static bool parentItem(QQmlListProperty<QObject> *, QObject *) { return true; } -}; - -template<class T> -struct ParentHandler<T, ChildrenMode::State> -{ - static bool parentItem(QQmlListProperty<QObject> *prop, QObject *item) - { - if (QAbstractState *state = qobject_cast<QAbstractState *>(item)) { - state->setParent(parentObject<T>(prop)); - return true; - } - return false; - } - - static bool unparentItem(QQmlListProperty<QObject> *, QObject *oldItem) - { - if (QAbstractState *state = qobject_cast<QAbstractState *>(oldItem)) { - state->setParent(nullptr); - return true; - } - return false; - } -}; - -template<class T> -struct ParentHandler<T, ChildrenMode::Transition> -{ - static bool parentItem(QQmlListProperty<QObject> *prop, QObject *item) - { - if (QAbstractTransition *trans = qobject_cast<QAbstractTransition *>(item)) { - parentObject<T>(prop)->addTransition(trans); - return true; - } - return false; - } - - static bool unparentItem(QQmlListProperty<QObject> *prop, QObject *oldItem) - { - if (QAbstractTransition *trans = qobject_cast<QAbstractTransition *>(oldItem)) { - parentObject<T>(prop)->removeTransition(trans); - return true; - } - return false; - } -}; - -template<class T> -struct ParentHandler<T, ChildrenMode::StateOrTransition> -{ - static bool parentItem(QQmlListProperty<QObject> *prop, QObject *oldItem) - { - return ParentHandler<T, ChildrenMode::State>::parentItem(prop, oldItem) - || ParentHandler<T, ChildrenMode::Transition>::parentItem(prop, oldItem); - } - - static bool unparentItem(QQmlListProperty<QObject> *prop, QObject *oldItem) - { - return ParentHandler<T, ChildrenMode::State>::unparentItem(prop, oldItem) - || ParentHandler<T, ChildrenMode::Transition>::unparentItem(prop, oldItem); - } -}; - -template <class T, ChildrenMode Mode> -class ChildrenPrivate -{ -public: - static void append(QQmlListProperty<QObject> *prop, QObject *item) - { - Handler::parentItem(prop, item); - static_cast<Self *>(prop->data)->children.append(item); - emit parentObject<T>(prop)->childrenChanged(); - } - - static int count(QQmlListProperty<QObject> *prop) - { - return static_cast<Self *>(prop->data)->children.count(); - } - - static QObject *at(QQmlListProperty<QObject> *prop, int index) - { - return static_cast<Self *>(prop->data)->children.at(index); - } - - static void clear(QQmlListProperty<QObject> *prop) - { - auto &children = static_cast<Self *>(prop->data)->children; - for (QObject *oldItem : qAsConst(children)) - Handler::unparentItem(prop, oldItem); - - children.clear(); - emit parentObject<T>(prop)->childrenChanged(); - } - - static void replace(QQmlListProperty<QObject> *prop, int index, QObject *item) - { - auto &children = static_cast<Self *>(prop->data)->children; - - Handler::unparentItem(prop, children.at(index)); - Handler::parentItem(prop, item); - - children.replace(index, item); - emit parentObject<T>(prop)->childrenChanged(); - } - - static void removeLast(QQmlListProperty<QObject> *prop) - { - Handler::unparentItem(prop, static_cast<Self *>(prop->data)->children.takeLast()); - emit parentObject<T>(prop)->childrenChanged(); - } - -private: - using Self = ChildrenPrivate<T, Mode>; - using Handler = ParentHandler<T, Mode>; - - QList<QObject *> children; -}; - -#endif diff --git a/src/imports/statemachine/finalstate.cpp b/src/imports/statemachine/finalstate.cpp deleted file mode 100644 index 4d4c6b2cc7..0000000000 --- a/src/imports/statemachine/finalstate.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "finalstate.h" - -#include <QQmlContext> -#include <QQmlEngine> -#include <QQmlInfo> - -FinalState::FinalState(QState *parent) - : QFinalState(parent) -{ -} - -QQmlListProperty<QObject> FinalState::children() -{ - return QQmlListProperty<QObject>(this, &m_children, - m_children.append, m_children.count, m_children.at, - m_children.clear, m_children.replace, m_children.removeLast); -} - -/*! - \qmltype FinalState - \inqmlmodule QtQml.StateMachine - \inherits QAbstractState - \ingroup statemachine-qmltypes - \since 5.4 - - \brief Provides a final state. - - - 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{State::finished}{finished}() signal is emitted. In - general, when a final substate (a child of a State) is entered, the parent - 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 - to it from another state. - - \section1 Example Usage - - \snippet qml/statemachine/finalstate.qml document - - \clearfloat - - \sa StateMachine, State -*/ diff --git a/src/imports/statemachine/finalstate.h b/src/imports/statemachine/finalstate.h deleted file mode 100644 index fef0e9c092..0000000000 --- a/src/imports/statemachine/finalstate.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQMLFINALSTATE_H -#define QQMLFINALSTATE_H - -#include "childrenprivate.h" -#include "statemachine.h" - -#include <QtCore/QFinalState> -#include <QtQml/QQmlListProperty> -#include <QtQml/qqml.h> - - -QT_BEGIN_NAMESPACE - -class FinalState : public QFinalState -{ - Q_OBJECT - Q_PROPERTY(QQmlListProperty<QObject> children READ children NOTIFY childrenChanged) - Q_CLASSINFO("DefaultProperty", "children") - QML_ELEMENT - QML_ADDED_IN_VERSION(1, 0) - -public: - explicit FinalState(QState *parent = 0); - - QQmlListProperty<QObject> children(); - -Q_SIGNALS: - void childrenChanged(); - -private: - ChildrenPrivate<FinalState, ChildrenMode::State> m_children; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/statemachine/plugin.cpp b/src/imports/statemachine/plugin.cpp deleted file mode 100644 index c370504029..0000000000 --- a/src/imports/statemachine/plugin.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "finalstate.h" -#include "signaltransition.h" -#include "state.h" -#include "statemachine.h" -#include "timeouttransition.h" -#include "statemachineforeign.h" - -#include <QHistoryState> -#include <QQmlExtensionPlugin> -#include <qqml.h> - -extern void qml_register_types_QtQml_StateMachine(); - -QT_BEGIN_NAMESPACE - -class QtQmlStateMachinePlugin : public QQmlEngineExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid) - -public: - QtQmlStateMachinePlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent) - { - volatile auto registration = &qml_register_types_QtQml_StateMachine; - Q_UNUSED(registration); - } -}; - -QT_END_NAMESPACE - -#include "plugin.moc" diff --git a/src/imports/statemachine/qmldir b/src/imports/statemachine/qmldir deleted file mode 100644 index 8bc3831208..0000000000 --- a/src/imports/statemachine/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -module QtQml.StateMachine -plugin qtqmlstatemachine -classname QtQmlStateMachinePlugin -typeinfo plugins.qmltypes diff --git a/src/imports/statemachine/signaltransition.cpp b/src/imports/statemachine/signaltransition.cpp deleted file mode 100644 index c600081820..0000000000 --- a/src/imports/statemachine/signaltransition.cpp +++ /dev/null @@ -1,349 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "signaltransition.h" - -#include <QStateMachine> -#include <QMetaProperty> -#include <QQmlInfo> -#include <QQmlEngine> -#include <QQmlContext> -#include <QQmlExpression> - -#include <private/qv4qobjectwrapper_p.h> -#include <private/qjsvalue_p.h> -#include <private/qv4scopedvalue_p.h> -#include <private/qqmlcontext_p.h> - -SignalTransition::SignalTransition(QState *parent) - : QSignalTransition(this, SIGNAL(invokeYourself()), parent), m_complete(false), m_signalExpression(nullptr) -{ - connect(this, SIGNAL(signalChanged()), SIGNAL(qmlSignalChanged())); -} - -bool SignalTransition::eventTest(QEvent *event) -{ - Q_ASSERT(event); - if (!QSignalTransition::eventTest(event)) - return false; - - if (m_guard.isEmpty()) - return true; - - QQmlContext *outerContext = QQmlEngine::contextForObject(this); - QQmlContext context(outerContext); - QQmlContextData::get(&context)->setImports(QQmlContextData::get(outerContext)->imports()); - - QStateMachine::SignalEvent *e = static_cast<QStateMachine::SignalEvent*>(event); - - // Set arguments as context properties - int count = e->arguments().count(); - QMetaMethod metaMethod = e->sender()->metaObject()->method(e->signalIndex()); - const auto parameterNames = metaMethod.parameterNames(); - for (int i = 0; i < count; i++) - context.setContextProperty(parameterNames[i], QVariant::fromValue(e->arguments().at(i))); - - QQmlExpression expr(m_guard, &context, this); - QVariant result = expr.evaluate(); - - return result.toBool(); -} - -void SignalTransition::onTransition(QEvent *event) -{ - if (m_signalExpression) { - QStateMachine::SignalEvent *e = static_cast<QStateMachine::SignalEvent*>(event); - m_signalExpression->evaluate(e->arguments()); - } - QSignalTransition::onTransition(event); -} - -const QJSValue& SignalTransition::signal() -{ - return m_signal; -} - -void SignalTransition::setSignal(const QJSValue &signal) -{ - if (m_signal.strictlyEquals(signal)) - return; - - QV4::ExecutionEngine *jsEngine = QQmlEngine::contextForObject(this)->engine()->handle(); - QV4::Scope scope(jsEngine); - - QObject *sender; - QMetaMethod signalMethod; - - m_signal = signal; - QJSValuePrivate::manageStringOnV4Heap(jsEngine, &m_signal); - - QV4::ScopedValue value(scope, QJSValuePrivate::asReturnedValue(&m_signal)); - - // Did we get the "slot" that can be used to invoke the signal? - if (QV4::QObjectMethod *signalSlot = value->as<QV4::QObjectMethod>()) { - sender = signalSlot->object(); - Q_ASSERT(sender); - signalMethod = sender->metaObject()->method(signalSlot->methodIndex()); - } else if (QV4::QmlSignalHandler *signalObject = value->as<QV4::QmlSignalHandler>()) { // or did we get the signal object (the one with the connect()/disconnect() functions) ? - sender = signalObject->object(); - Q_ASSERT(sender); - signalMethod = sender->metaObject()->method(signalObject->signalIndex()); - } else { - qmlWarning(this) << tr("Specified signal does not exist."); - return; - } - - QSignalTransition::setSenderObject(sender); - QSignalTransition::setSignal(signalMethod.methodSignature()); - - connectTriggered(); -} - -QQmlScriptString SignalTransition::guard() const -{ - return m_guard; -} - -void SignalTransition::setGuard(const QQmlScriptString &guard) -{ - if (m_guard == guard) - return; - - m_guard = guard; - emit guardChanged(); -} - -void SignalTransition::invoke() -{ - emit invokeYourself(); -} - -void SignalTransition::connectTriggered() -{ - if (!m_complete || !m_compilationUnit) - return; - - QObject *target = senderObject(); - QQmlData *ddata = QQmlData::get(this); - QQmlRefPointer<QQmlContextData> ctxtdata = ddata ? ddata->outerContext : nullptr; - - Q_ASSERT(m_bindings.count() == 1); - const QV4::CompiledData::Binding *binding = m_bindings.at(0); - Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Script); - - QV4::ExecutionEngine *jsEngine = QQmlEngine::contextForObject(this)->engine()->handle(); - QV4::Scope scope(jsEngine); - QV4::Scoped<QV4::QObjectMethod> qobjectSignal(scope, QJSValuePrivate::asReturnedValue(&m_signal)); - Q_ASSERT(qobjectSignal); - QMetaMethod metaMethod = target->metaObject()->method(qobjectSignal->methodIndex()); - int signalIndex = QMetaObjectPrivate::signalIndex(metaMethod); - - auto f = m_compilationUnit->runtimeFunctions[binding->value.compiledScriptIndex]; - if (ctxtdata) { - QQmlRefPointer<QQmlBoundSignalExpression> expression( - new QQmlBoundSignalExpression(target, signalIndex, ctxtdata, this, f), - QQmlRefPointer<QQmlBoundSignalExpression>::Adopt); - expression->setNotifyOnValueChanged(false); - m_signalExpression = expression; - } else { - m_signalExpression.adopt(nullptr); - } -} - -void SignalTransitionParser::verifyBindings(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &props) -{ - for (int ii = 0; ii < props.count(); ++ii) { - const QV4::CompiledData::Binding *binding = props.at(ii); - - QString propName = compilationUnit->stringAt(binding->propertyNameIndex); - - if (propName != QLatin1String("onTriggered")) { - error(props.at(ii), SignalTransition::tr("Cannot assign to non-existent property \"%1\"").arg(propName)); - return; - } - - if (binding->type != QV4::CompiledData::Binding::Type_Script) { - error(binding, SignalTransition::tr("SignalTransition: script expected")); - return; - } - } -} - -void SignalTransitionParser::applyBindings( - QObject *object, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, - const QList<const QV4::CompiledData::Binding *> &bindings) -{ - SignalTransition *st = qobject_cast<SignalTransition*>(object); - st->m_compilationUnit = compilationUnit; - st->m_bindings = bindings; -} - -/*! - \qmltype QAbstractTransition - \inqmlmodule QtQml.StateMachine - \omit - \ingroup statemachine-qmltypes - \endomit - \since 5.4 - - \brief The QAbstractTransition type is the base type of transitions between QAbstractState objects. - - The QAbstractTransition type is the abstract base type of transitions - between states (QAbstractState objects) of a StateMachine. - QAbstractTransition is part of \l{The Declarative State Machine Framework}. - - The sourceState() property has the source of the transition. The - targetState and targetStates properties return the target(s) of the - transition. - - The triggered() signal is emitted when the transition has been triggered. - - Do not use QAbstractTransition directly; use SignalTransition or - TimeoutTransition instead. - - \sa SignalTransition, TimeoutTransition -*/ - -/*! - \qmlproperty bool QAbstractTransition::sourceState - \readonly sourceState - - \brief The source state (parent) of this transition. -*/ - -/*! - \qmlproperty QAbstractState QAbstractTransition::targetState - - \brief The target state of this transition. - - If a transition has no target state, the transition may still be - triggered, but this will not cause the state machine's configuration to - change (i.e. the current state will not be exited and re-entered). -*/ - -/*! - \qmlproperty list<QAbstractState> QAbstractTransition::targetStates - - \brief The target states of this transition. - - If multiple states are specified, they all must be descendants of the - same parallel group state. -*/ - -/*! - \qmlsignal QAbstractTransition::triggered() - - This signal is emitted when the transition has been triggered. -*/ - -/*! - \qmltype QSignalTransition - \inqmlmodule QtQml.StateMachine - \inherits QAbstractTransition - \omit - \ingroup statemachine-qmltypes - \endomit - \since 5.4 - - \brief The QSignalTransition type provides a transition based on a Qt signal. - - Do not use QSignalTransition directly; use SignalTransition or - TimeoutTransition instead. - - \sa SignalTransition, TimeoutTransition -*/ - -/*! - \qmlproperty string QSignalTransition::signal - - \brief The signal which is associated with this signal transition. -*/ - -/*! - \qmlproperty QObject QSignalTransition::senderObject - - \brief The sender object which is associated with this signal transition. -*/ - - -/*! - \qmltype SignalTransition - \inqmlmodule QtQml.StateMachine - \inherits QSignalTransition - \ingroup statemachine-qmltypes - \since 5.4 - - \brief The SignalTransition type provides a transition based on a Qt signal. - - SignalTransition is part of \l{The Declarative State Machine Framework}. - - \section1 Example Usage - - \snippet qml/statemachine/signaltransition.qml document - - \clearfloat - - \sa StateMachine, FinalState, TimeoutTransition -*/ - -/*! - \qmlproperty signal SignalTransition::signal - - \brief The signal which is associated with this signal transition. - - \snippet qml/statemachine/signaltransitionsignal.qml document -*/ - -/*! - \qmlproperty bool SignalTransition::guard - - Guard conditions affect the behavior of a state machine by enabling - transitions only when they evaluate to true and disabling them when - they evaluate to false. - - When the signal associated with this signal transition is emitted the - guard condition is evaluated. In the guard condition the arguments - of the signal can be used as demonstrated in the example below. - - \snippet qml/statemachine/guardcondition.qml document - - \sa signal -*/ - -#include "moc_signaltransition.cpp" diff --git a/src/imports/statemachine/signaltransition.h b/src/imports/statemachine/signaltransition.h deleted file mode 100644 index 7cef80bb4c..0000000000 --- a/src/imports/statemachine/signaltransition.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIGNALTRANSITION_H -#define SIGNALTRANSITION_H - -#include <QtCore/QSignalTransition> -#include <QtCore/QVariant> -#include <QtQml/QJSValue> - -#include <QtQml/qqmlscriptstring.h> -#include <QtQml/qqmlparserstatus.h> -#include <private/qqmlcustomparser_p.h> -#include <private/qqmlrefcount_p.h> -#include <private/qqmlboundsignal_p.h> - -QT_BEGIN_NAMESPACE - -class SignalTransition : public QSignalTransition, public QQmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QJSValue signal READ signal WRITE setSignal NOTIFY qmlSignalChanged) - Q_PROPERTY(QQmlScriptString guard READ guard WRITE setGuard NOTIFY guardChanged) - QML_ELEMENT - QML_ADDED_IN_VERSION(1, 0) - -public: - explicit SignalTransition(QState *parent = nullptr); - - QQmlScriptString guard() const; - void setGuard(const QQmlScriptString &guard); - - bool eventTest(QEvent *event) override; - void onTransition(QEvent *event) override; - - const QJSValue &signal(); - void setSignal(const QJSValue &signal); - - Q_INVOKABLE void invoke(); - -Q_SIGNALS: - void guardChanged(); - void invokeYourself(); - /*! - * \internal - */ - void qmlSignalChanged(); - -private: - void classBegin() override { m_complete = false; } - void componentComplete() override { m_complete = true; connectTriggered(); } - void connectTriggered(); - - friend class SignalTransitionParser; - QJSValue m_signal; - QQmlScriptString m_guard; - bool m_complete; - QQmlRefPointer<QV4::ExecutableCompilationUnit> m_compilationUnit; - QList<const QV4::CompiledData::Binding *> m_bindings; - QQmlRefPointer<QQmlBoundSignalExpression> m_signalExpression; -}; - -class SignalTransitionParser : public QQmlCustomParser -{ -public: - void verifyBindings(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &props) override; - void applyBindings(QObject *object, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override; -}; - -template<> -inline QQmlCustomParser *qmlCreateCustomParser<SignalTransition>() -{ - return new SignalTransitionParser; -} - -QT_END_NAMESPACE - -#endif diff --git a/src/imports/statemachine/state.cpp b/src/imports/statemachine/state.cpp deleted file mode 100644 index ff0f55f197..0000000000 --- a/src/imports/statemachine/state.cpp +++ /dev/null @@ -1,240 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "state.h" - -#include <QQmlContext> -#include <QQmlEngine> -#include <QQmlInfo> - -State::State(QState *parent) - : QState(parent) -{ -} - -void State::componentComplete() -{ - if (this->machine() == nullptr) { - static bool once = false; - if (!once) { - once = true; - qmlWarning(this) << "No top level StateMachine found. Nothing will run without a StateMachine."; - } - } -} - -QQmlListProperty<QObject> State::children() -{ - return QQmlListProperty<QObject>(this, &m_children, - m_children.append, m_children.count, m_children.at, - m_children.clear, m_children.replace, m_children.removeLast); -} - -/*! - \qmltype QAbstractState - \inqmlmodule QtQml.StateMachine - \omit - \ingroup statemachine-qmltypes - \endomit - \since 5.4 - - \brief The QAbstractState type is the base type of States of a StateMachine. - - Do not use QAbstractState directly; use State, FinalState or - StateMachine instead. - - \sa StateMachine, State -*/ - -/*! - \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. - - \sa active, exited -*/ - -/*! - \qmlsignal QAbstractState::exited() - - This signal is emitted when the State becomes inactive. - - \sa active, entered -*/ - -/*! - \qmltype State - \inqmlmodule QtQml.StateMachine - \inherits QAbstractState - \ingroup statemachine-qmltypes - \since 5.4 - - \brief Provides a general-purpose state for StateMachine. - - 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 - - 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 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 - 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 State::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 State::errorState - - \brief The error state of this state. -*/ - -/*! - \qmlproperty QAbstractState State::initialState - - \brief The initial state of this state (one of its child states). -*/ - -/*! - \qmlsignal State::finished() - - This signal is emitted when a final child state of this state is entered. - - \sa QAbstractState::active, QAbstractState::entered, QAbstractState::exited -*/ - -/*! - \qmltype HistoryState - \inqmlmodule QtQml.StateMachine - \inherits QAbstractState - \ingroup statemachine-qmltypes - \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, State -*/ - -/*! - \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 HistoryState.ShallowHistory. - - This enum specifies the type of history that a HistoryState records. - \list - \li HistoryState.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 HistoryState.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 -*/ - -#include "moc_state.cpp" diff --git a/src/imports/statemachine/state.h b/src/imports/statemachine/state.h deleted file mode 100644 index 8cb454f3cf..0000000000 --- a/src/imports/statemachine/state.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef STATE_H -#define STATE_H - -#include "childrenprivate.h" - -#include <QtCore/QState> -#include <QtQml/QQmlParserStatus> -#include <QtQml/QQmlListProperty> -#include <QtQml/qqml.h> - -QT_BEGIN_NAMESPACE - -class State : public QState, public QQmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QQmlListProperty<QObject> children READ children NOTIFY childrenChanged) - Q_CLASSINFO("DefaultProperty", "children") - QML_ELEMENT - QML_ADDED_IN_VERSION(1, 0) - -public: - explicit State(QState *parent = 0); - - void classBegin() override {} - void componentComplete() override; - - QQmlListProperty<QObject> children(); - -Q_SIGNALS: - void childrenChanged(); - -private: - ChildrenPrivate<State, ChildrenMode::StateOrTransition> m_children; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/imports/statemachine/statemachine.cpp b/src/imports/statemachine/statemachine.cpp deleted file mode 100644 index de6c84227d..0000000000 --- a/src/imports/statemachine/statemachine.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "statemachine.h" - -#include <QAbstractTransition> -#include <QQmlContext> -#include <QQmlEngine> -#include <QQmlInfo> - -#include <private/qqmlopenmetaobject_p.h> -#include <private/qqmlengine_p.h> - -StateMachine::StateMachine(QObject *parent) - : QStateMachine(parent), m_completed(false), m_running(false) -{ - connect(this, SIGNAL(runningChanged(bool)), SIGNAL(qmlRunningChanged())); - connect(this, SIGNAL(childModeChanged()), SLOT(checkChildMode())); -} - -bool StateMachine::isRunning() const -{ - return QStateMachine::isRunning(); -} - -void StateMachine::setRunning(bool running) -{ - if (m_completed) - QStateMachine::setRunning(running); - else - m_running = running; -} - -void StateMachine::checkChildMode() -{ - if (childMode() != QState::ExclusiveStates) { - qmlWarning(this) << "Setting the childMode of a StateMachine to anything else than\n" - "QState.ExclusiveStates will result in an invalid state machine,\n" - "and can lead to incorrect behavior!"; - } -} - -void StateMachine::componentComplete() -{ - if (QStateMachine::initialState() == nullptr && childMode() == QState::ExclusiveStates) - qmlWarning(this) << "No initial state set for StateMachine"; - - // Everything is proper setup, now start the state-machine if we got - // asked to do so. - m_completed = true; - if (m_running) - setRunning(true); -} - -QQmlListProperty<QObject> StateMachine::children() -{ - return QQmlListProperty<QObject>(this, &m_children, - m_children.append, m_children.count, m_children.at, - m_children.clear, m_children.replace, m_children.removeLast); -} - -/*! - \qmltype StateMachine - \inqmlmodule QtQml.StateMachine - \inherits State - \ingroup statemachine-qmltypes - \since 5.4 - - \brief Provides a hierarchical finite state machine. - - StateMachine is based on the concepts and notation of - \l{http://www.wisdom.weizmann.ac.il/~dharel/SCANNED.PAPERS/Statecharts.pdf}{Statecharts}. - StateMachine is part of \l{The Declarative State Machine Framework}. - - A state machine manages a set of states and transitions between those - states; these states and transitions define a state graph. Once a state - graph has been built, the state machine can execute it. StateMachine's - execution algorithm is based on the \l{http://www.w3.org/TR/scxml/}{State Chart XML (SCXML)} - 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{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 - initial state is entered. - - The state machine processes events and takes transitions until a - top-level final state is entered; the state machine then emits the - finished() signal. You can also stop() the state machine - explicitly (you can also set running property to false). - The stopped signal is emitted in this case. - - \section1 Example Usage - The following snippet shows a state machine that will finish when a button - is clicked: - - \snippet qml/statemachine/simplestatemachine.qml document - - If an error is encountered, the machine will look for an - \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 - erroneous state, the machine will stop executing and an error message will - be printed to the console. - - \warning Setting the childMode of a StateMachine to anything else than QState::ExclusiveStates - will result in an invalid state machine, and can lead to incorrect behavior. - - \clearfloat - - \sa QAbstractState, State, SignalTransition, TimeoutTransition, HistoryState {The Declarative State Machine Framework} -*/ - -/*! - \qmlproperty enumeration StateMachine::globalRestorePolicy - - \brief The restore policy for states of this state machine. - - The default value of this property is QState.DontRestoreProperties. - - This enum specifies the restore policy type. The restore policy - takes effect when the machine enters a state which sets one or more - properties. If the restore policy is set to QState.RestoreProperties, - the state machine will save the original value of the property before the - new value is set. - - Later, when the machine either enters a state which does not set a - value for the given property, the property will automatically be restored - to its initial value. - - Only one initial value will be saved for any given property. If a value - for a property has already been saved by the state machine, it will not be - overwritten until the property has been successfully restored. - - \list - \li QState.DontRestoreProperties The state machine should not save the initial values of properties and restore them later. - \li QState.RestoreProperties The state machine should save the initial values of properties and restore them later. - \endlist -*/ - -/*! - \qmlproperty bool StateMachine::running - - \brief The running state of this state machine. - \sa start(), stop() -*/ - -/*! - \qmlproperty string StateMachine::errorString - \readonly errorString - - \brief The error string of this state machine. -*/ - - -/*! - \qmlmethod StateMachine::start() - - Starts this state machine. The machine will reset its configuration and - transition to the initial state. When a final top-level state (FinalState) - is entered, the machine will emit the finished() signal. - - \note A state machine will not run without a running event loop, such as - the main application event loop started with QCoreApplication::exec() or - QApplication::exec(). - - \sa started, State::finished, stop(), State::initialState, running -*/ - -/*! - \qmlsignal StateMachine::started() - - This signal is emitted when the state machine has entered its initial state - (State::initialState). - - \sa running, start(), State::finished -*/ - -/*! - \qmlmethod StateMachine::stop() - - Stops this state machine. The state machine will stop processing events - and then emit the stopped signal. - - \sa stopped, start(), running -*/ - -/*! - \qmlsignal StateMachine::stopped() - - This signal is emitted when the state machine has stopped. - - \sa running, stop(), State::finished -*/ - -#include "moc_statemachine.cpp" diff --git a/src/imports/statemachine/statemachine.h b/src/imports/statemachine/statemachine.h deleted file mode 100644 index 85ac4cf26b..0000000000 --- a/src/imports/statemachine/statemachine.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef STATEMACHINE_H -#define STATEMACHINE_H - -#include "childrenprivate.h" - -#include <QtCore/QStateMachine> -#include <QtQml/QQmlParserStatus> -#include <QtQml/QQmlListProperty> -#include <QtQml/qqml.h> - -QT_BEGIN_NAMESPACE - -class StateMachine : public QStateMachine, public QQmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QQmlListProperty<QObject> children READ children NOTIFY childrenChanged) - - // Override to delay execution after componentComplete() - Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY qmlRunningChanged) - - Q_CLASSINFO("DefaultProperty", "children") - QML_ELEMENT - QML_ADDED_IN_VERSION(1, 0) - -public: - explicit StateMachine(QObject *parent = 0); - - void classBegin() override {} - void componentComplete() override; - QQmlListProperty<QObject> children(); - - bool isRunning() const; - void setRunning(bool running); - -private Q_SLOTS: - void checkChildMode(); - -Q_SIGNALS: - void childrenChanged(); - /*! - * \internal - */ - void qmlRunningChanged(); - -private: - ChildrenPrivate<StateMachine, ChildrenMode::StateOrTransition> m_children; - bool m_completed; - bool m_running; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/imports/statemachine/statemachine.pro b/src/imports/statemachine/statemachine.pro deleted file mode 100644 index cff81c2416..0000000000 --- a/src/imports/statemachine/statemachine.pro +++ /dev/null @@ -1,27 +0,0 @@ -CXX_MODULE = qml -TARGET = qtqmlstatemachine -TARGETPATH = QtQml/StateMachine -QML_IMPORT_VERSION = $$QT_VERSION - -QT = core-private qml-private - -SOURCES = \ - $$PWD/finalstate.cpp \ - $$PWD/signaltransition.cpp \ - $$PWD/state.cpp \ - $$PWD/statemachine.cpp \ - $$PWD/timeouttransition.cpp \ - $$PWD/plugin.cpp - -HEADERS = \ - $$PWD/childrenprivate.h \ - $$PWD/finalstate.h \ - $$PWD/signaltransition.h \ - $$PWD/state.h \ - $$PWD/statemachine.h \ - $$PWD/timeouttransition.h \ - $$PWD/statemachineforeign.h - -CONFIG += qmltypes install_qmltypes - -load(qml_plugin) diff --git a/src/imports/statemachine/statemachineforeign.h b/src/imports/statemachine/statemachineforeign.h deleted file mode 100644 index 7543d55fdf..0000000000 --- a/src/imports/statemachine/statemachineforeign.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef STATEMACHINEFOREIGN_H -#define STATEMACHINEFOREIGN_H - -#include <QtQml/qqml.h> -#include <QtCore/qhistorystate.h> -#include <QtCore/qstate.h> -#include <QtCore/qabstractstate.h> -#include <QtCore/qsignaltransition.h> - -struct QHistoryStateForeign -{ - Q_GADGET - QML_FOREIGN(QHistoryState) - QML_NAMED_ELEMENT(HistoryState) - QML_ADDED_IN_VERSION(1, 0) -}; - -struct QStateForeign -{ - Q_GADGET - QML_FOREIGN(QState) - QML_NAMED_ELEMENT(QState) - QML_ADDED_IN_VERSION(1, 0) - QML_UNCREATABLE("Don't use this, use State instead.") -}; - -struct QAbstractStateForeign -{ - Q_GADGET - QML_FOREIGN(QAbstractState) - QML_NAMED_ELEMENT(QAbstractState) - QML_ADDED_IN_VERSION(1, 0) - QML_UNCREATABLE("Don't use this, use State instead.") -}; - -struct QSignalTransitionForeign -{ - Q_GADGET - QML_FOREIGN(QSignalTransition) - QML_NAMED_ELEMENT(QSignalTransition) - QML_ADDED_IN_VERSION(1, 0) - QML_UNCREATABLE("Don't use this, use SignalTransition instead.") -}; - -#endif // STATEMACHINEFOREIGN_H diff --git a/src/imports/statemachine/timeouttransition.cpp b/src/imports/statemachine/timeouttransition.cpp deleted file mode 100644 index b0400b7d00..0000000000 --- a/src/imports/statemachine/timeouttransition.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "timeouttransition.h" - -#include <QQmlInfo> -#include <QTimer> -#include <QState> - -TimeoutTransition::TimeoutTransition(QState* parent) - : QSignalTransition((m_timer = new QTimer), SIGNAL(timeout()), parent) -{ - m_timer->setSingleShot(true); - m_timer->setInterval(1000); -} - -TimeoutTransition::~TimeoutTransition() -{ - delete m_timer; -} - -int TimeoutTransition::timeout() const -{ - return m_timer->interval(); -} - -void TimeoutTransition::setTimeout(int timeout) -{ - if (timeout != m_timer->interval()) { - m_timer->setInterval(timeout); - emit timeoutChanged(); - } -} - -void TimeoutTransition::componentComplete() -{ - QState *state = qobject_cast<QState*>(parent()); - if (!state) { - qmlWarning(this) << "Parent needs to be a State"; - return; - } - - connect(state, SIGNAL(entered()), m_timer, SLOT(start())); - connect(state, SIGNAL(exited()), m_timer, SLOT(stop())); - if (state->active()) - m_timer->start(); -} - -/*! - \qmltype TimeoutTransition - \inqmlmodule QtQml.StateMachine - \inherits QSignalTransition - \ingroup statemachine-qmltypes - \since 5.4 - - \brief The TimeoutTransition type provides a transition based on a timer. - - \l{Timer} type can be combined with SignalTransition to enact more complex - timeout based transitions. - - TimeoutTransition is part of \l{The Declarative State Machine Framework}. - - \section1 Example Usage - - \snippet qml/statemachine/timeouttransition.qml document - - \clearfloat - - \sa StateMachine, SignalTransition, FinalState, HistoryState -*/ - -/*! - \qmlproperty int TimeoutTransition::timeout - - \brief The timeout interval in milliseconds. -*/ - -#include "moc_timeouttransition.cpp" diff --git a/src/imports/statemachine/timeouttransition.h b/src/imports/statemachine/timeouttransition.h deleted file mode 100644 index 3d056b5e41..0000000000 --- a/src/imports/statemachine/timeouttransition.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TIMEOUTTRANSITION_H -#define TIMEOUTTRANSITION_H - -#include <QtCore/QSignalTransition> -#include <QtQml/QQmlParserStatus> -#include <QtQml/qqml.h> - -QT_BEGIN_NAMESPACE -class QTimer; - -class TimeoutTransition : public QSignalTransition, public QQmlParserStatus -{ - Q_OBJECT - Q_PROPERTY(int timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged) - Q_INTERFACES(QQmlParserStatus) - QML_ELEMENT - QML_ADDED_IN_VERSION(1, 0) - -public: - TimeoutTransition(QState *parent = nullptr); - ~TimeoutTransition(); - - int timeout() const; - void setTimeout(int timeout); - - void classBegin() override {} - void componentComplete() override; - -Q_SIGNALS: - void timeoutChanged(); - -private: - QTimer *m_timer; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/qml/doc/images/statemachine-button-history.png b/src/qml/doc/images/statemachine-button-history.png Binary files differdeleted file mode 100644 index 0462b3b99b..0000000000 --- a/src/qml/doc/images/statemachine-button-history.png +++ /dev/null diff --git a/src/qml/doc/images/statemachine-button-nested.png b/src/qml/doc/images/statemachine-button-nested.png Binary files differdeleted file mode 100644 index 762ac14df1..0000000000 --- a/src/qml/doc/images/statemachine-button-nested.png +++ /dev/null diff --git a/src/qml/doc/images/statemachine-button.png b/src/qml/doc/images/statemachine-button.png Binary files differdeleted file mode 100644 index 10102bdf2c..0000000000 --- a/src/qml/doc/images/statemachine-button.png +++ /dev/null diff --git a/src/qml/doc/images/statemachine-finished.png b/src/qml/doc/images/statemachine-finished.png Binary files differdeleted file mode 100644 index 0ac081d6ba..0000000000 --- a/src/qml/doc/images/statemachine-finished.png +++ /dev/null diff --git a/src/qml/doc/images/statemachine-nonparallel.png b/src/qml/doc/images/statemachine-nonparallel.png Binary files differdeleted file mode 100644 index f9850a74a6..0000000000 --- a/src/qml/doc/images/statemachine-nonparallel.png +++ /dev/null diff --git a/src/qml/doc/images/statemachine-parallel.png b/src/qml/doc/images/statemachine-parallel.png Binary files differdeleted file mode 100644 index a65c297f5b..0000000000 --- a/src/qml/doc/images/statemachine-parallel.png +++ /dev/null diff --git a/src/qml/doc/qtqml.qdocconf b/src/qml/doc/qtqml.qdocconf index 786a81846c..23999cf597 100644 --- a/src/qml/doc/qtqml.qdocconf +++ b/src/qml/doc/qtqml.qdocconf @@ -40,7 +40,6 @@ headerdirs += .. \ ../../qml sourcedirs += .. \ - ../../imports/statemachine \ ../../qml exampledirs += ../../../examples/qml \ diff --git a/src/qml/doc/snippets/qml/statemachine/Button.qml b/src/qml/doc/snippets/qml/statemachine/Button.qml deleted file mode 100644 index 38d13475a9..0000000000 --- a/src/qml/doc/snippets/qml/statemachine/Button.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.1 -import QtQuick.Window 2.1 - -Item { - id: container - - property alias text: buttonLabel.text - property alias label: buttonLabel - signal clicked - property alias containsMouse: mouseArea.containsMouse - property alias pressed: mouseArea.pressed - implicitHeight: Math.max(Screen.pixelDensity * 7, buttonLabel.implicitHeight * 1.2) - implicitWidth: Math.max(Screen.pixelDensity * 11, buttonLabel.implicitWidth * 1.3) - height: implicitHeight - width: implicitWidth - property bool checkable: false - property bool checked: false - - SystemPalette { id: palette } - - Rectangle { - id: frame - anchors.fill: parent - color: palette.button - gradient: Gradient { - GradientStop { position: 0.0; color: mouseArea.pressed ? Qt.darker(palette.button, 1.3) : palette.button } - GradientStop { position: 1.0; color: Qt.darker(palette.button, 1.3) } - } - antialiasing: true - radius: height / 6 - border.color: Qt.darker(palette.button, 1.5) - border.width: 1 - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked() - hoverEnabled: true - } - - Text { - id: buttonLabel - text: container.text - color: palette.buttonText - anchors.centerIn: parent - } -} diff --git a/src/qml/doc/snippets/qml/statemachine/basicstate.qml b/src/qml/doc/snippets/qml/statemachine/basicstate.qml deleted file mode 100644 index d8da3f939d..0000000000 --- a/src/qml/doc/snippets/qml/statemachine/basicstate.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 -import QtQml.StateMachine 1.0 as DSM - -Rectangle { - DSM.StateMachine { - id: stateMachine - initialState: state - running: true - DSM.State { - id: state - } - } -} -//! [document] diff --git a/src/qml/doc/snippets/qml/statemachine/finalstate.qml b/src/qml/doc/snippets/qml/statemachine/finalstate.qml deleted file mode 100644 index 984daadf36..0000000000 --- a/src/qml/doc/snippets/qml/statemachine/finalstate.qml +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 -import QtQml.StateMachine 1.0 as DSM - -Rectangle { - DSM.StateMachine { - id: stateMachine - initialState: state - running: true - DSM.State { - id: state - DSM.TimeoutTransition { - targetState: finalState - timeout: 200 - } - } - DSM.FinalState { - id: finalState - } - onFinished: console.log("state finished") - } -} -//! [document] diff --git a/src/qml/doc/snippets/qml/statemachine/guardcondition.qml b/src/qml/doc/snippets/qml/statemachine/guardcondition.qml deleted file mode 100644 index f1ec89b6ba..0000000000 --- a/src/qml/doc/snippets/qml/statemachine/guardcondition.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 -import QtQml.StateMachine 1.0 as DSM - -Rectangle { - Button { - anchors.fill: parent - id: button - DSM.StateMachine { - DSM.State { - DSM.SignalTransition { - targetState: finalState - signal: button.mysignal - // the guard condition uses the mystr string argument from mysignal - guard: mystr == "test" - } - } - DSM.FinalState { - id: finalState - } - } - // define the signal the SignalTransition is connected with - signal mysignal(mystr: string) - // on clicking the button emit the signal with a single string argument - onClicked: button.mysignal("test") - } -} -//! [document] diff --git a/src/qml/doc/snippets/qml/statemachine/historystate.qml b/src/qml/doc/snippets/qml/statemachine/historystate.qml deleted file mode 100644 index 28e4e06756..0000000000 --- a/src/qml/doc/snippets/qml/statemachine/historystate.qml +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 -import QtQml.StateMachine 1.0 as DSM - -Rectangle { - Button { - anchors.fill: parent - id: button - text: "Press me" - DSM.StateMachine { - id: stateMachine - initialState: parentState - running: true - DSM.State { - id: parentState - initialState: child2 - onEntered: console.log("parentState entered") - onExited: console.log("parentState exited") - DSM.State { - id: child1 - onEntered: console.log("child1 entered") - onExited: console.log("child1 exited") - } - DSM.State { - id: child2 - onEntered: console.log("child2 entered") - onExited: console.log("child2 exited") - } - DSM.HistoryState { - id: historyState - defaultState: child1 - } - DSM.SignalTransition { - targetState: historyState - - // Clicking the button will cause the state machine to enter the child state - // that parentState was in the last time parentState was exited, or the history state's default - // state if parentState has never been entered. - signal: button.clicked - } - } - } - } -} -//! [document] diff --git a/src/qml/doc/snippets/qml/statemachine/signaltransition.qml b/src/qml/doc/snippets/qml/statemachine/signaltransition.qml deleted file mode 100644 index 925d728ed7..0000000000 --- a/src/qml/doc/snippets/qml/statemachine/signaltransition.qml +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 -import QtQml.StateMachine 1.0 as DSM - -Rectangle { - DSM.StateMachine { - id: stateMachine - initialState: state - running: true - DSM.State { - id: state - DSM.SignalTransition { - targetState: finalState - signal: button.clicked - guard: guardButton.checked - } - } - DSM.FinalState { - id: finalState - } - onFinished: Qt.quit() - } - Row { - spacing: 2 - Button { - id: button - text: "Finish state" - } - - Button { - id: guardButton - checkable: true - text: checked ? "Press to block the SignalTransition" : "Press to unblock the SignalTransition" - } - } -} -//! [document] diff --git a/src/qml/doc/snippets/qml/statemachine/signaltransitionsignal.qml b/src/qml/doc/snippets/qml/statemachine/signaltransitionsignal.qml deleted file mode 100644 index d5510cb44d..0000000000 --- a/src/qml/doc/snippets/qml/statemachine/signaltransitionsignal.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 -import QtQml.StateMachine 1.0 as DSM - -Rectangle { - Button { - anchors.fill: parent - id: button - DSM.StateMachine { - DSM.State { - DSM.SignalTransition { - targetState: finalState - signal: button.clicked - } - } - DSM.FinalState { - id: finalState - } - } - } -} -//! [document] diff --git a/src/qml/doc/snippets/qml/statemachine/simplestatemachine.qml b/src/qml/doc/snippets/qml/statemachine/simplestatemachine.qml deleted file mode 100644 index fc1768f4a0..0000000000 --- a/src/qml/doc/snippets/qml/statemachine/simplestatemachine.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 -import QtQml.StateMachine 1.0 as DSM - -Rectangle { - Button { - anchors.fill: parent - id: button - text: "Finish state" - DSM.StateMachine { - id: stateMachine - initialState: state - running: true - DSM.State { - id: state - DSM.SignalTransition { - targetState: finalState - signal: button.clicked - } - } - DSM.FinalState { - id: finalState - } - onFinished: Qt.quit() - } - } -} -//! [document] diff --git a/src/qml/doc/snippets/qml/statemachine/statemachine-button-history.qml b/src/qml/doc/snippets/qml/statemachine/statemachine-button-history.qml deleted file mode 100644 index b6cd325c03..0000000000 --- a/src/qml/doc/snippets/qml/statemachine/statemachine-button-history.qml +++ /dev/null @@ -1,159 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 -import QtQml.StateMachine 1.0 - -Rectangle { -//![0] - Row { - anchors.fill: parent - spacing: 2 - Button { - id: button - // change the button label to the active state id - text: s11.active ? "s11" : s12.active ? "s12" : s13.active ? "s13" : "s3" - } - Button { - id: interruptButton - text: s1.active ? "Interrupt" : "Resume" - } - Button { - id: quitButton - text: "quit" - } - } - - StateMachine { - id: stateMachine - // set the initial state - initialState: s1 - - // start the state machine - running: true - - State { - id: s1 - // set the initial state - initialState: s11 - - // create a transition from s1 to s2 when the button is clicked - SignalTransition { - targetState: s2 - signal: quitButton.clicked - } - // do something when the state enters/exits - onEntered: console.log("s1 entered") - onExited: console.log("s1 exited") - State { - id: s11 - // create a transition from s1 to s2 when the button is clicked - SignalTransition { - targetState: s12 - signal: button.clicked - } - // do something when the state enters/exits - onEntered: console.log("s11 entered") - onExited: console.log("s11 exited") - } - - State { - id: s12 - // create a transition from s2 to s3 when the button is clicked - SignalTransition { - targetState: s13 - signal: button.clicked - } - // do something when the state enters/exits - onEntered: console.log("s12 entered") - onExited: console.log("s12 exited") - } - State { - id: s13 - // create a transition from s3 to s1 when the button is clicked - SignalTransition { - targetState: s1 - signal: button.clicked - } - // do something when the state enters/exits - onEntered: console.log("s13 entered") - onExited: console.log("s13 exited") - } - - // create a transition from s1 to s3 when the button is clicked - SignalTransition { - targetState: s3 - signal: interruptButton.clicked - } - HistoryState { - id: s1h - } - } - FinalState { - id: s2 - onEntered: console.log("s2 entered") - onExited: console.log("s2 exited") - } - State { - id: s3 - SignalTransition { - targetState: s1h - signal: interruptButton.clicked - } - // do something when the state enters/exits - onEntered: console.log("s3 entered") - onExited: console.log("s3 exited") - } - onFinished: Qt.quit() - } -//![0] -} -//! [document] 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 deleted file mode 100644 index 77cf253b73..0000000000 --- a/src/qml/doc/snippets/qml/statemachine/statemachine-button-nested-ignore-quit.qml +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 -import QtQml.StateMachine 1.0 - -Rectangle { - Row { - anchors.fill: parent - spacing: 2 - Button { - id: button - // change the button label to the active state id - text: s11.active ? "s11" : s12.active ? "s12" : "s13" - } - Button { - id: quitButton - text: "quit" - } - } - - StateMachine { - id: stateMachine - // set the initial state - initialState: s1 - - // start the state machine - running: true - - State { - id: s1 - // set the initial state - initialState: s11 - - // create a transition from s1 to s2 when the button is clicked - SignalTransition { - targetState: s2 - signal: quitButton.clicked - } - // do something when the state enters/exits - onEntered: console.log("s1 entered") - onExited: console.log("s1 exited") - State { - id: s11 - // create a transition from s11 to s12 when the button is clicked - SignalTransition { - targetState: s12 - signal: button.clicked - } - // do something when the state enters/exits - onEntered: console.log("s11 entered") - onExited: console.log("s11 exited") - } - -//![0] - State { - id: s12 - // create a transition from s12 to s13 when the button is clicked - SignalTransition { - targetState: s13 - signal: button.clicked - } - - // ignore Quit button when we are in state 12 - SignalTransition { - targetState: s12 - signal: quitButton.clicked - } - - // do something when the state enters/exits - onEntered: console.log("s12 entered") - onExited: console.log("s12 exited") - } -//![0] - - State { - id: s13 - // create a transition from s13 to s11 when the button is clicked - SignalTransition { - targetState: s11 - signal: button.clicked - } - // do something when the state enters/exits - onEntered: console.log("s13 entered") - onExited: console.log("s13 exited") - } - } - FinalState { - id: s2 - onEntered: console.log("s2 entered") - onExited: console.log("s2 exited") - } - onFinished: Qt.quit() - } -} -//! [document] diff --git a/src/qml/doc/snippets/qml/statemachine/statemachine-button-nested.qml b/src/qml/doc/snippets/qml/statemachine/statemachine-button-nested.qml deleted file mode 100644 index 19ab69315b..0000000000 --- a/src/qml/doc/snippets/qml/statemachine/statemachine-button-nested.qml +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 -import QtQml.StateMachine 1.0 - -Rectangle { -//![0] - Row { - anchors.fill: parent - spacing: 2 - Button { - id: button - // change the button label to the active state id - text: s11.active ? "s11" : s12.active ? "s12" : "s13" - } - Button { - id: quitButton - text: "quit" - } - } - - StateMachine { - id: stateMachine - // set the initial state - initialState: s1 - - // start the state machine - running: true - - State { - id: s1 - // set the initial state - initialState: s11 - - // create a transition from s1 to s2 when the button is clicked - SignalTransition { - targetState: s2 - signal: quitButton.clicked - } - // do something when the state enters/exits - onEntered: console.log("s1 entered") - onExited: console.log("s1 exited") - State { - id: s11 - // create a transition from s11 to s12 when the button is clicked - SignalTransition { - targetState: s12 - signal: button.clicked - } - // do something when the state enters/exits - onEntered: console.log("s11 entered") - onExited: console.log("s11 exited") - } - - State { - id: s12 - // create a transition from s12 to s13 when the button is clicked - SignalTransition { - targetState: s13 - signal: button.clicked - } - // do something when the state enters/exits - onEntered: console.log("s12 entered") - onExited: console.log("s12 exited") - } - State { - id: s13 - // create a transition from s13 to s11 when the button is clicked - SignalTransition { - targetState: s11 - signal: button.clicked - } - // do something when the state enters/exits - onEntered: console.log("s13 entered") - onExited: console.log("s13 exited") - } - } - FinalState { - id: s2 - onEntered: console.log("s2 entered") - onExited: console.log("s2 exited") - } - onFinished: Qt.quit() - } -//![0] -} -//! [document] diff --git a/src/qml/doc/snippets/qml/statemachine/statemachine-button.qml b/src/qml/doc/snippets/qml/statemachine/statemachine-button.qml deleted file mode 100644 index 8fcbe6195f..0000000000 --- a/src/qml/doc/snippets/qml/statemachine/statemachine-button.qml +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 -import QtQml.StateMachine 1.0 - -Rectangle { -//![0] - Button { - anchors.fill: parent - id: button - - // change the button label to the active state id - text: s1.active ? "s1" : s2.active ? "s2" : "s3" - } - - StateMachine { - id: stateMachine - // set the initial state - initialState: s1 - - // start the state machine - running: true - - State { - id: s1 - // create a transition from s1 to s2 when the button is clicked - SignalTransition { - targetState: s2 - signal: button.clicked - } - // do something when the state enters/exits - onEntered: console.log("s1 entered") - onExited: console.log("s1 exited") - } - - State { - id: s2 - // create a transition from s2 to s3 when the button is clicked - SignalTransition { - targetState: s3 - signal: button.clicked - } - // do something when the state enters/exits - onEntered: console.log("s2 entered") - onExited: console.log("s2 exited") - } - State { - id: s3 - // create a transition from s3 to s1 when the button is clicked - SignalTransition { - targetState: s1 - signal: button.clicked - } - // do something when the state enters/exits - onEntered: console.log("s3 entered") - onExited: console.log("s3 exited") - } - } -//![0] -} -//! [document] diff --git a/src/qml/doc/snippets/qml/statemachine/timeouttransition.qml b/src/qml/doc/snippets/qml/statemachine/timeouttransition.qml deleted file mode 100644 index b629e84941..0000000000 --- a/src/qml/doc/snippets/qml/statemachine/timeouttransition.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 -import QtQml.StateMachine 1.0 as DSM - -Rectangle { - Button { - anchors.fill: parent - id: button - text: "Finish state" - enabled: !stateMachine.running - onClicked: stateMachine.running = true - DSM.StateMachine { - id: stateMachine - initialState: state - running: true - DSM.State { - id: state - DSM.TimeoutTransition { - targetState: finalState - timeout: 1000 - } - } - DSM.FinalState { - id: finalState - } - } - } -} -//! [document] diff --git a/src/qml/doc/src/statemachine.qdoc b/src/qml/doc/src/statemachine.qdoc deleted file mode 100644 index 231b85af76..0000000000 --- a/src/qml/doc/src/statemachine.qdoc +++ /dev/null @@ -1,328 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \qmlmodule QtQml.StateMachine 1.\QtMinorVersion - \title Qt QML State Machine QML Types - \brief Provides QML types to create and execute state graphs. - - The following is a list of QML types provided by the module: -*/ - - -/*! - \page qmlstatemachine.html - \title The Declarative State Machine Framework - \brief Overview of the Declarative State Machine Framework for constructing and executing state graphs. - - \ingroup frameworks-technologies - - \tableofcontents - - The Declarative State Machine Framework provides types for creating and - executing state graphs in QML. It is similar to the C++ State Machine - framework based on Harel's - \l{Statecharts: A visual formalism for complex systems}, which - is also the basis for UML state diagrams. Like its - \l{The State Machine Framework}{C++ counterpart}, the framework provides an - API and execution model based on \l{State Chart XML: State Machine Notation for - Control Abstraction}{State Chart XML (SCXML)} - to embed the elements and semantics of statecharts in QML applications. - - For user interfaces with multiple visual states, independent of the - application's logical state, consider using QML States and Transitions. - - These following QML types are provided by framework to create event-driven - state machines: - - \annotatedlist statemachine-qmltypes - - \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 \QtMinorVersion - import QtQuick 2.\1 - import QtQml.StateMachine 1.\1 - - 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 \QtMinorVersion - import QtQuick 2.\1 - import QtQml.StateMachine 1.\1 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 - s3. The state machine is controlled by a single Button; when the button - is clicked, the machine transitions to another state. Initially, the state - machine is in state \c s1. The following is a state chart showing the - different states in our example. - - \image statemachine-button.png - - The following snippet shows the code needed to create such a state machine. - - \snippet qml/statemachine/statemachine-button.qml 0 - - The state machine runs asynchronously to become part of your application's - event loop. - - \section1 State Machines That Finish - - 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{State::finished}{finished} - signal and halts. - - All you need to do to introduce a final state in the graph is create a - FinalState object and use it as the target of one or more transitions. - - \section1 Sharing Transitions - - Assume we wanted the user to be able to quit the application at any time by - clicking a Quit button. In order to achieve this, we need to create a final - state and make it the target of a transition associated with the Quit - button's \e clicked() signal. We could add a transition for each state; - however, this seems redundant and one would also have to - remember to add such a transition from every new state that is added in the - future. - - We can achieve the same behavior (namely that clicking the Quit button quits - the state machine, regardless of which state the state machine is in) by - grouping states \c s1, \c s2 and \c s3. This is done by creating a new - top-level state and making the three original states children of the new - state. The following diagram shows the new state machine. - - \image statemachine-button-nested.png - - The three original states have been renamed \c s11, \c s12 and \c s13 to - reflect that they are now childrens of the new top-level state, \c s1. Child - states implicitly inherit the transitions of their parent state. This means - it is now sufficient to add a single transition from \c s1 to the final - state, \c s2. New states added to \c s1 will automatically inherit this - transition. - - All that's needed to group states is to specify the proper parent when the - state is created. You also need to specify which of the child states is the - initial one (the child state the state machine should enter when the - parent state is the target of a transition). - - \snippet qml/statemachine/statemachine-button-nested.qml 0 - - In this case we want the application to quit when the state machine is - finished, so the machine's \e finished() signal is connected to the - application's \e quit() slot. - - A child state can override an inherited transition. For example, the - following code adds a transition that effectively causes the Quit button to - be ignored when the state machine is in state, \c s12. - - \snippet qml/statemachine/statemachine-button-nested-ignore-quit.qml 0 - - A transition can have any state as its target irrespective of where the - target state is in the state hierarchy. - - \section1 Using History States - - Imagine that we wanted to add an "interrupt" mechanism to the example - discussed in the previous section; the user should be able to click a button - to have the state machine perform some non-related task, after which the - state machine should resume whatever it was doing before (i.e. return to the - old state, which is one of the three states in this case). - - Such behavior can easily be modeled using \e{history states}. A history - state (HistoryState object) is a pseudo-state that represents the child - state that the parent state was in before it exited last. - - A history state is created as a child of the state for which we wish to - record the current child state; when the state machine detects the presence - of such a state at runtime, it automatically records the current (real) - child state when the parent state exits. A transition to the history - state is in fact a transition to the child state that the state machine had - previously saved; the state machine automatically "forwards" the transition - to the real child state. - - The following diagram shows the state machine after the interrupt mechanism - has been added. - - \image statemachine-button-history.png - - The following code shows how it can be implemented; in this example we - simply display a message box when \c s3 is entered, then immediately return - to the previous child state of \c s1 via the history state. - - \snippet qml/statemachine/statemachine-button-history.qml 0 - - \section1 Using Parallel States - - Assume that you wanted to model a set of mutually exclusive properties of a - car in a single state machine. Let's say the properties we are interested in - are Clean vs Dirty, and Moving vs Not moving. It would take four mutually - exclusive states and eight transitions to represent the states and freely - move between all possible combinations as shown in the following state chart. - - \image statemachine-nonparallel.png - - If we added a third property (say, Red vs Blue), the total number of states - would double, to eight; and if we added a fourth property (say, Enclosed vs - Convertible), the total number of states would double again, to 16. - - This exponential increase can be reduced using parallel states, which enables - linear growth in the number of states and transitions as we add more - properties. Furthermore, states can be added to or removed from the parallel - state without affecting any of their sibling states. The following state - chart shows the different paralles states for the car example. - - \image statemachine-parallel.png - - To create a parallel state group, set childMode to QState.ParallelStates. - - \qml - State { - id: s1 - childMode: QState.ParallelStates - State { - id: s11 - } - State { - id: s12 - } - } - \endqml - - When a parallel state group is entered, all its child states will be - simultaneously entered. Transitions within the individual child states - operate normally. However, any of the child states may take a transition - which exits the parent state. When this happens, the parent state and all of - its child states are exited. - - The parallelism in the State Machine framework follows an interleaved - semantics. All parallel operations will be executed in a single, atomic step - of the event processing, so no event can interrupt the parallel operations. - However, events will still be processed sequentially, as the machine itself - is single threaded. For example, consider the situation where there are two - transitions that exit the same parallel state group, and their conditions - become true simultaneously. In this case, the event that is processed last - of the two will not have any effect. - - \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 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{State::finished}{finished}. We use a signal transition to cause this event to - trigger a state change: - - \qml - State { - id: s1 - SignalTransition { - targetState: s2 - signal: s1.finished - } - } - \endqml - - Using final states in composite states is useful when you want to hide the - internal details of a composite state. The outside world should be able to - enter the state and get a notification when the state has completed its work, - without the need to know the internal details. This is a very powerful - abstraction and encapsulation mechanism when building complex (deeply nested) - state machines. (In the above example, you could of course create a transition - directly from \c s1 's \c done state rather than relying on \c s1 's - finished() signal, but with the consequence that implementation details of - \c s1 are exposed and depended on). - - For parallel state groups, the State::finished signal is emitted when \e - all the child states have entered final states. - - \section1 Targetless Transitions - - A transition need not have a target state. A transition without a target can - be triggered the same way as any other transition; the difference is that - it doesn't cause any state changes. This allows you to react to a signal or - event when your machine is in a certain state, without having to leave that - state. For example: - - \qml - Button { - id: button - text: "button" - StateMachine { - id: stateMachine - initialState: s1 - running: true - State { - id: s1 - SignalTransition { - signal: button.clicked - onTriggered: console.log("button pressed") - } - } - } - } - \endqml - - The "button pressed" message will be displayed each time the button is clicked, but the - state machine will remain in its current state (s1). If the target state - were explicitly set to s1, s1 would be exited and re-entered each - time (the QAbstractState::entered and QAbstractState::exited - signals would be emitted). - - \section1 Related Information - - \list - \li \l{Qt QML State Machine QML Types} - \li \l{The State Machine Framework} - \endlist -*/ diff --git a/src/quick/doc/qtquick.qdocconf b/src/quick/doc/qtquick.qdocconf index 6a1bcac10a..63297f5344 100644 --- a/src/quick/doc/qtquick.qdocconf +++ b/src/quick/doc/qtquick.qdocconf @@ -72,8 +72,7 @@ sourcedirs += ../../plugins excludedirs += ../../imports/models \ ../../imports/labsmodels \ ../../imports/testlib \ - ../../imports/workerscript \ - ../../imports/statemachine + ../../imports/workerscript excludefiles += ../util/qquickpropertychanges_p.h examples.fileextensions += "*.qm" diff --git a/tests/auto/qml/.prev_CMakeLists.txt b/tests/auto/qml/.prev_CMakeLists.txt index 3ac0c2f5be..d3c338aa4b 100644 --- a/tests/auto/qml/.prev_CMakeLists.txt +++ b/tests/auto/qml/.prev_CMakeLists.txt @@ -28,7 +28,6 @@ add_subdirectory(qtqmlmodules) add_subdirectory(qquickfolderlistmodel) add_subdirectory(qqmlapplicationengine) add_subdirectory(qqmlsettings) -add_subdirectory(qqmlstatemachine) add_subdirectory(qmldiskcache) add_subdirectory(qqmlmetatype) if(TARGET Qt::Widgets) diff --git a/tests/auto/qml/CMakeLists.txt b/tests/auto/qml/CMakeLists.txt index 4466f630e6..3bd4f0334b 100644 --- a/tests/auto/qml/CMakeLists.txt +++ b/tests/auto/qml/CMakeLists.txt @@ -28,7 +28,6 @@ add_subdirectory(qtqmlmodules) add_subdirectory(qquickfolderlistmodel) add_subdirectory(qqmlapplicationengine) add_subdirectory(qqmlsettings) -add_subdirectory(qqmlstatemachine) add_subdirectory(qmldiskcache) add_subdirectory(qqmlmetatype) if(TARGET Qt::Widgets) diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index 714d0a6c84..5409361142 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -30,7 +30,6 @@ PUBLICTESTS += \ qquickfolderlistmodel \ qqmlapplicationengine \ qqmlsettings \ - qqmlstatemachine \ qmldiskcache PRIVATETESTS += \ diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index 6f59cca1b1..92a5787bdb 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -570,27 +570,6 @@ void tst_qqmlmetatype::unregisterAttachedProperties() QScopedPointer<QObject> obj(c.create()); QVERIFY(obj); } - - qmlClearTypeRegistrations(); - { - QQmlEngine e; - QQmlComponent c(&e); - - // The extra import shuffles the type IDs around, so that we - // get a different ID for the attached properties. If the attached - // properties aren't properly cleared, this will crash. - c.setData("import QtQml.StateMachine 1.0 \n" - "import QtQuick 2.2 \n" - "Item { KeyNavigation.up: null }", dummy); - - const QQmlType attachedType = QQmlMetaType::qmlType("QtQuick/KeyNavigation", - QTypeRevision::fromVersion(2, 2)); - QCOMPARE(attachedType.attachedPropertiesType(QQmlEnginePrivate::get(&e)), - attachedType.metaObject()); - - QScopedPointer<QObject> obj(c.create()); - QVERIFY(obj); - } } class Grouped : public QObject diff --git a/tests/auto/qml/qqmlstatemachine/CMakeLists.txt b/tests/auto/qml/qqmlstatemachine/CMakeLists.txt deleted file mode 100644 index 4ffe1c3906..0000000000 --- a/tests/auto/qml/qqmlstatemachine/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# Generated from qqmlstatemachine.pro. - -##################################################################### -## tst_qqmlstatemachine Test: -##################################################################### - -qt_add_test(tst_qqmlstatemachine - SOURCES - ../../shared/util.cpp ../../shared/util.h - tst_qqmlstatemachine.cpp - INCLUDE_DIRECTORIES - ../../shared - PUBLIC_LIBRARIES - Qt::CorePrivate - Qt::Gui - Qt::GuiPrivate - Qt::QmlPrivate - Qt::QuickPrivate -) - -## Scopes: -##################################################################### - -qt_extend_target(tst_qqmlstatemachine CONDITION ANDROID OR IOS - DEFINES - QT_QMLTEST_DATADIR=\\\":/data\\\" -) - -qt_extend_target(tst_qqmlstatemachine CONDITION NOT ANDROID AND NOT IOS - DEFINES - QT_QMLTEST_DATADIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/data\\\" -) diff --git a/tests/auto/qml/qqmlstatemachine/data/cppsignal.qml b/tests/auto/qml/qqmlstatemachine/data/cppsignal.qml deleted file mode 100644 index a469185cbc..0000000000 --- a/tests/auto/qml/qqmlstatemachine/data/cppsignal.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQml 2.0 - -import QtQml.StateMachine 1.0 - -import CppObjectEnum 1.0 - -StateMachine { - id: stateMachine - initialState: state0 - - State { - id: state0 - SignalTransition { - targetState: state1 - signal: _cppObject.mySignal - // signalState is mySignal's parameter - guard: signalState === CppObject.State1 - } - } - - State { - id: state1 - SignalTransition { - targetState: state2 - signal: _cppObject.mySignal - // signalState is mySignal's parameter - guard: signalState === CppObject.State2 - } - onEntered: _cppObject.objectState = CppObject.State1 - } - - FinalState { - id: state2 - onEntered: _cppObject.objectState = CppObject.State2 - } - Component.onCompleted: stateMachine.running = true -} diff --git a/tests/auto/qml/qqmlstatemachine/qqmlstatemachine.pro b/tests/auto/qml/qqmlstatemachine/qqmlstatemachine.pro deleted file mode 100644 index 635f2fa5e0..0000000000 --- a/tests/auto/qml/qqmlstatemachine/qqmlstatemachine.pro +++ /dev/null @@ -1,9 +0,0 @@ -CONFIG += testcase -TARGET = tst_qqmlstatemachine -osx:CONFIG -= app_bundle - -SOURCES += tst_qqmlstatemachine.cpp - -include (../../shared/util.pri) - -QT += core-private gui-private qml-private quick-private gui testlib diff --git a/tests/auto/qml/qqmlstatemachine/tst_qqmlstatemachine.cpp b/tests/auto/qml/qqmlstatemachine/tst_qqmlstatemachine.cpp deleted file mode 100644 index a6f0d65453..0000000000 --- a/tests/auto/qml/qqmlstatemachine/tst_qqmlstatemachine.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <QQmlComponent> -#include <QQmlContext> -#include <QQmlEngine> -#include <QTest> -#include "../../shared/util.h" - -class tst_qqmlstatemachine : public QQmlDataTest -{ - Q_OBJECT -public: - tst_qqmlstatemachine(); - -private slots: - void tst_cppObjectSignal(); -}; - - -class CppObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(ObjectState objectState READ objectState WRITE setObjectState NOTIFY objectStateChanged) - Q_ENUMS(ObjectState) -public: - enum ObjectState { - State0, - State1, - State2 - }; - -public: - CppObject() {} - - ObjectState objectState() const { return m_objectState; } - void setObjectState(ObjectState objectState) { m_objectState = objectState; emit objectStateChanged();} - -signals: - void objectStateChanged(); - void mySignal(int signalState); - -private: - ObjectState m_objectState = State0; -}; - -tst_qqmlstatemachine::tst_qqmlstatemachine() -{ - QVERIFY(-1 != qmlRegisterUncreatableType<CppObject>("CppObjectEnum", 1, 0, "CppObject", QString())); -} - -void tst_qqmlstatemachine::tst_cppObjectSignal() -{ - CppObject cppObject; - QQmlEngine engine; - QQmlComponent component(&engine, testFileUrl("cppsignal.qml")); - QVERIFY2(!component.isError(), qPrintable(component.errorString())); - - QQmlContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("_cppObject", &cppObject); - QScopedPointer<QObject> rootObject(component.create()); - QVERIFY(rootObject != nullptr); - - // wait for state machine to start - QTRY_VERIFY(rootObject->property("running").toBool()); - - // emit signal from cpp - emit cppObject.mySignal(CppObject::State1); - - // check if the signal was propagated - QTRY_COMPARE(cppObject.objectState(), CppObject::State1); - - // emit signal from cpp - emit cppObject.mySignal(CppObject::State2); - - // check if the signal was propagated - QTRY_COMPARE(cppObject.objectState(), CppObject::State2); - - // wait for state machine to finish - QTRY_VERIFY(!rootObject->property("running").toBool()); -} - - -QTEST_MAIN(tst_qqmlstatemachine) - -#include "tst_qqmlstatemachine.moc" diff --git a/tests/auto/qmltest/CMakeLists.txt b/tests/auto/qmltest/CMakeLists.txt index 184c1c1216..ac950263b5 100644 --- a/tests/auto/qmltest/CMakeLists.txt +++ b/tests/auto/qmltest/CMakeLists.txt @@ -23,7 +23,6 @@ add_subdirectory(rectangle) add_subdirectory(selftests) add_subdirectory(shadersource) add_subdirectory(stability) -add_subdirectory(statemachine) add_subdirectory(text) add_subdirectory(textedit) add_subdirectory(textinput) diff --git a/tests/auto/qmltest/qmltest.pro b/tests/auto/qmltest/qmltest.pro index 8ad1541cbc..3463d1735f 100644 --- a/tests/auto/qmltest/qmltest.pro +++ b/tests/auto/qmltest/qmltest.pro @@ -23,7 +23,6 @@ SUBDIRS += \ selftests \ shadersource \ stability \ - statemachine \ text \ textedit \ textinput \ diff --git a/tests/auto/qmltest/statemachine/CMakeLists.txt b/tests/auto/qmltest/statemachine/CMakeLists.txt deleted file mode 100644 index fafaf382d8..0000000000 --- a/tests/auto/qmltest/statemachine/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Generated from statemachine.pro. - -##################################################################### -## statemachine Test: -##################################################################### - -qt_add_test(statemachine - GUI - QMLTEST - PUBLIC_LIBRARIES - Qt::Gui -) diff --git a/tests/auto/qmltest/statemachine/statemachine.pro b/tests/auto/qmltest/statemachine/statemachine.pro deleted file mode 100644 index a7938e7003..0000000000 --- a/tests/auto/qmltest/statemachine/statemachine.pro +++ /dev/null @@ -1 +0,0 @@ -CONFIG += qmltestcase diff --git a/tests/auto/qmltest/statemachine/tst_anonymousstate.qml b/tests/auto/qmltest/statemachine/tst_anonymousstate.qml deleted file mode 100644 index 65ce58860c..0000000000 --- a/tests/auto/qmltest/statemachine/tst_anonymousstate.qml +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtTest 1.1 -import QtQml.StateMachine 1.0 - -TestCase { - StateMachine { - State { - } - } - name: "anonymousState" - // no real tests, just make sure it runs -} diff --git a/tests/auto/qmltest/statemachine/tst_enumguard.qml b/tests/auto/qmltest/statemachine/tst_enumguard.qml deleted file mode 100644 index d871ef980a..0000000000 --- a/tests/auto/qmltest/statemachine/tst_enumguard.qml +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtTest 1.1 -import QtQml.StateMachine 1.0 - -TestCase { - id: testCase - StateMachine { - id: machine - initialState: startState - State { - id: startState - SignalTransition { - id: signalTrans - signal: testCase.mysignal - guard: alignment === QState.ParallelStates - targetState: finalState - } - } - FinalState { - id: finalState - } - } - - SignalSpy { - id: finalStateActive - target: finalState - signalName: "activeChanged" - } - - signal mysignal(int alignment) - - name: "testEnumGuard" - function test_enumGuard() - { - // Start statemachine, should not have reached finalState yet. - machine.start() - tryCompare(finalStateActive, "count", 0) - tryCompare(machine, "running", true) - - // Emit the signalTrans.signal which will evaluate the guard. The - // guard should return true, finalState be reached and the - // statemachine be stopped. - testCase.mysignal(QState.ParallelStates) - tryCompare(finalStateActive, "count", 1) - tryCompare(machine, "running", false) - - // Restart machine. - machine.start() - tryCompare(machine, "running", true) - tryCompare(finalStateActive, "count", 2) - - // Emit signal that makes the signalTrans.guard return false. The - // finalState should not have been triggered. - testCase.mysignal(QState.ExclusiveStates) - tryCompare(finalStateActive, "count", 2) - tryCompare(machine, "running", true) - } -} diff --git a/tests/auto/qmltest/statemachine/tst_guardcondition.qml b/tests/auto/qmltest/statemachine/tst_guardcondition.qml deleted file mode 100644 index e364b38c81..0000000000 --- a/tests/auto/qmltest/statemachine/tst_guardcondition.qml +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtTest 1.1 -import QtQml.StateMachine 1.0 - -TestCase { - id: testCase - StateMachine { - id: machine - initialState: startState - State { - id: startState - SignalTransition { - id: signalTrans - signal: testCase.mysignal - guard: mystr == "test1" - targetState: finalState - } - } - FinalState { - id: finalState - } - } - - SignalSpy { - id: finalStateActive - target: finalState - signalName: "activeChanged" - } - - signal mysignal(string mystr, bool mybool, int myint) - - name: "testGuardCondition" - function test_guardCondition() - { - // Start statemachine, should not have reached finalState yet. - machine.start() - tryCompare(finalStateActive, "count", 0) - tryCompare(machine, "running", true) - - // Emit the signalTrans.signal which will evaluate the guard. The - // guard should return true, finalState be reached and the - // statemachine be stopped. - testCase.mysignal("test1", true, 2) - tryCompare(finalStateActive, "count", 1) - tryCompare(machine, "running", false) - - // Restart machine. - machine.start() - tryCompare(machine, "running", true) - tryCompare(finalStateActive, "count", 2) - - // Emit signal that makes the signalTrans.guard return false. The - // finalState should not have been triggered. - testCase.mysignal("test2", true, 2) - tryCompare(finalStateActive, "count", 2) - tryCompare(machine, "running", true) - - // Change the guard in javascript to test that boolean true/false - // works as expected. - signalTrans.guard = false; - testCase.mysignal("test1", true, 2) - tryCompare(finalStateActive, "count", 2) - tryCompare(machine, "running", true) - signalTrans.guard = true; - testCase.mysignal("test1", true, 2) - tryCompare(finalStateActive, "count", 3) - tryCompare(machine, "running", false) - } -} diff --git a/tests/auto/qmltest/statemachine/tst_historystate.qml b/tests/auto/qmltest/statemachine/tst_historystate.qml deleted file mode 100644 index ba94b85b10..0000000000 --- a/tests/auto/qmltest/statemachine/tst_historystate.qml +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtTest 1.1 -import QtQml.StateMachine 1.0 - -TestCase { - - StateMachine { - id: stateMachine - initialState: historyState1 - - State { - id: state1 - SignalTransition { - id: st1 - targetState: state2 - } - } - - State { - id: state2 - initialState: historyState2 - HistoryState { - id: historyState2 - defaultState: state21 - } - State { - id: state21 - } - } - - HistoryState { - id: historyState1 - defaultState: state1 - } - } - - SignalSpy { - id: state1SpyActive - target: state1 - signalName: "activeChanged" - } - - SignalSpy { - id: state2SpyActive - target: state2 - signalName: "activeChanged" - } - - - function test_historyStateAsInitialState() - { - stateMachine.start(); - tryCompare(stateMachine, "running", true); - tryCompare(state1SpyActive, "count" , 1); - tryCompare(state2SpyActive, "count" , 0); - st1.invoke(); - tryCompare(state1SpyActive, "count" , 2); - tryCompare(state2SpyActive, "count" , 1); - tryCompare(state21, "active", true); - tryCompare(state1, "active", false); - } -} diff --git a/tests/auto/qmltest/statemachine/tst_initialstate.qml b/tests/auto/qmltest/statemachine/tst_initialstate.qml deleted file mode 100644 index ba5db1976c..0000000000 --- a/tests/auto/qmltest/statemachine/tst_initialstate.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtTest 1.1 -import QtQml.StateMachine 1.0 - -TestCase { - StateMachine { - id: myStateMachine - initialState: myState; - running: true - State { - id: myState - } - } - - name: "initialStateTest" - function test_initialState() { - tryCompare(myStateMachine, "running", true); - compare(myState.active, true); - myStateMachine.running = false; - tryCompare(myStateMachine, "running", false); - myStateMachine.running = true; - tryCompare(myStateMachine, "running", true); - tryCompare(myState, "active", true); - } -} diff --git a/tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml b/tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml deleted file mode 100644 index f506ed72b2..0000000000 --- a/tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtTest 1.1 -import QtQml.StateMachine 1.0 - -TestCase { - StateMachine { - id: myStateMachine - initialState: parentState - State { - id: parentState - initialState: childState1 - State { - id: childState1 - } - State { - id: childState2 - } - } - } - name: "nestedInitalStates" - - function test_nestedInitalStates() { - compare(myStateMachine.running, false); - compare(parentState.active, false); - compare(childState1.active, false); - compare(childState2.active, false); - myStateMachine.start(); - tryCompare(myStateMachine, "running", true); - tryCompare(parentState, "active", true); - tryCompare(childState1, "active", true); - compare(childState2.active, false); - } -} diff --git a/tests/auto/qmltest/statemachine/tst_nestedstatemachine.qml b/tests/auto/qmltest/statemachine/tst_nestedstatemachine.qml deleted file mode 100644 index 0a63092c3c..0000000000 --- a/tests/auto/qmltest/statemachine/tst_nestedstatemachine.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtTest 1.1 -import QtQml.StateMachine 1.0 - -TestCase { - StateMachine { - id: myStateMachine - initialState: parentState - State { - id: parentState - initialState: childStateMachine - StateMachine { - id: childStateMachine - initialState: childState2 - State { - id: childState1 - } - State { - id: childState2 - } - } - } - } - name: "nestedStateMachine" - - function test_nestedStateMachine() { - compare(myStateMachine.running, false); - compare(parentState.active, false); - compare(childStateMachine.running, false); - compare(childState1.active, false); - compare(childState2.active, false); - myStateMachine.start(); - tryCompare(myStateMachine, "running", true); - tryCompare(parentState, "active", true); - tryCompare(childStateMachine, "running", true); - tryCompare(childState1, "active", false); - tryCompare(childState2, "active", true); - } -} diff --git a/tests/auto/qmltest/statemachine/tst_parallelmachine.qml b/tests/auto/qmltest/statemachine/tst_parallelmachine.qml deleted file mode 100644 index eb996c7718..0000000000 --- a/tests/auto/qmltest/statemachine/tst_parallelmachine.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtTest 1.1 -import QtQml.StateMachine 1.0 - -TestCase { - StateMachine { - id: myStateMachine - initialState: rootState - State { - id: rootState - childMode: State.ParallelStates - State { - id: childState1 - childMode: State.ParallelStates - State { - id: childState11 - } - State { - id: childState12 - } - } - State { - id: childState2 - initialState: childState21 - State { - id: childState21 - } - State { - id: childState22 - } - } - } - } - name: "nestedParallelMachineStates" - - function test_nestedInitalStates() { - // uncomment me after vm problems are fixed. - // compare(myStateMachine.running, false); - compare(childState1.active, false); - compare(childState11.active, false); - compare(childState12.active, false); - compare(childState2.active, false); - compare(childState21.active, false); - compare(childState22.active, false); - myStateMachine.start(); - tryCompare(myStateMachine, "running", true); - tryCompare(childState1, "active", true); - tryCompare(childState11, "active", true); - tryCompare(childState12, "active", true); - tryCompare(childState2, "active", true); - tryCompare(childState21, "active", true); - tryCompare(childState22, "active", false); - } -} diff --git a/tests/auto/qmltest/statemachine/tst_signaltransition.qml b/tests/auto/qmltest/statemachine/tst_signaltransition.qml deleted file mode 100644 index a57826855a..0000000000 --- a/tests/auto/qmltest/statemachine/tst_signaltransition.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Ford Motor Company -** Copyright (C) 2017 The Qt Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtTest 1.1 -import QtQml.StateMachine 1.0 - -TestCase { - id: testCase - StateMachine { - id: machine - initialState: startState - State { - id: startState - SignalTransition { - id: signalTrans - signal: testCase.onMysignal - targetState: finalState - } - } - FinalState { - id: finalState - } - } - - SignalSpy { - id: finalStateActive - target: finalState - signalName: "activeChanged" - } - - signal mysignal() - - name: "testSignalTransition" - function test_signalTransition() - { - // Start statemachine, should not have reached finalState yet. - machine.start() - tryCompare(finalStateActive, "count", 0) - tryCompare(machine, "running", true) - - testCase.mysignal() - tryCompare(finalStateActive, "count", 1) - tryCompare(machine, "running", false) - } -} diff --git a/tests/auto/qmltest/statemachine/tst_trafficlight.qml b/tests/auto/qmltest/statemachine/tst_trafficlight.qml deleted file mode 100644 index ebbab0a5f4..0000000000 --- a/tests/auto/qmltest/statemachine/tst_trafficlight.qml +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtTest 1.1 -import QtQml.StateMachine 1.0 - -TestCase { - StateMachine { - id: machine - initialState: red - FinalState { - id: finalState - } - - State { - id: red - initialState: justRed - State { - id: justRed - SignalTransition { - id: e1 - targetState: waitingForGreen - } - SignalTransition { - id: finalSignal - targetState: finalState - } - } - State { - id: waitingForGreen - TimeoutTransition { - id: e2 - targetState: yellowred - timeout: 30 - } - } - } - State { - id: yellowred - TimeoutTransition { - id: e3 - targetState: green - timeout: 10 - } - } - State { - id: green - TimeoutTransition { - id: e4 - targetState: yellow - timeout: 50 - } - } - State { - id: yellow - TimeoutTransition { - id: e5 - targetState: red - timeout: 10 - } - } - } - - SignalSpy { - id: machineSpyRunning - target: machine - signalName: "runningChanged" - } - - SignalSpy { - id: redSpyActive - target: red - signalName: "activeChanged" - } - - SignalSpy { - id: yellowredSpyActive - target: yellowred - signalName: "activeChanged" - } - - SignalSpy { - id: greenSpyActive - target: green - signalName: "activeChanged" - } - - SignalSpy { - id: yellowSpyActive - target: yellow - signalName: "activeChanged" - } - - - name: "testTrafficLight" - function test_trafficLight() - { - var i = 1; - machine.start(); - tryCompare(machine, "running", true); - tryCompare(machineSpyRunning, "count", 1); - tryCompare(redSpyActive, "count", 1); - for (; i <= 5; ++i) { - e1.invoke(); - tryCompare(yellowredSpyActive, "count", i * 2); - tryCompare(greenSpyActive, "count", i * 2); - tryCompare(redSpyActive, "count", i * 2 + 1); - tryCompare(yellowSpyActive, "count", i * 2); - } - finalSignal.guard = false; - finalSignal.invoke(); - wait(100); - tryCompare(machine, "running", true); - finalSignal.guard = true; - finalSignal.invoke(); - tryCompare(machine, "running", false); - tryCompare(redSpyActive, "count", i * 2); - } -} diff --git a/tests/auto/qmltest/statemachine/tst_triggeredArguments1.qml b/tests/auto/qmltest/statemachine/tst_triggeredArguments1.qml deleted file mode 100644 index 34c172aded..0000000000 --- a/tests/auto/qmltest/statemachine/tst_triggeredArguments1.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtTest 1.1 -import QtQml.StateMachine 1.0 - -TestCase { - id: testCase - - property string mystr - property bool mybool - property int myint - - StateMachine { - id: machine - initialState: startState - running: true - State { - id: startState - SignalTransition { - id: signalTrans - signal: testCase.mysignal - onTriggered: { - testCase.mystr = mystr - testCase.mybool = mybool - testCase.myint = myint - } - targetState: finalState - } - } - FinalState { - id: finalState - } - } - - signal mysignal(string mystr, bool mybool, int myint) - - name: "testTriggeredArguments1" - function test_triggeredArguments() - { - tryCompare(startState, "active", true) - - // Emit the signalTrans.signal - testCase.mysignal("test1", true, 2) - compare(testCase.mystr, "test1") - compare(testCase.mybool, true) - compare(testCase.myint, 2) - } -} diff --git a/tests/auto/qmltest/statemachine/tst_triggeredArguments2.qml b/tests/auto/qmltest/statemachine/tst_triggeredArguments2.qml deleted file mode 100644 index f23cc14152..0000000000 --- a/tests/auto/qmltest/statemachine/tst_triggeredArguments2.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Ford Motor Company -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtTest 1.1 -import QtQml.StateMachine 1.0 - -TestCase { - id: testCase - - property string mystr - property bool mybool - property int myint - - StateMachine { - id: machine - initialState: startState - running: true - State { - id: startState - SignalTransition { - id: signalTrans - signal: testCase.mysignal - onTriggered: function(strarg, boolarg, intarg) { - testCase.mystr = strarg - testCase.mybool = boolarg - testCase.myint = intarg - } - targetState: finalState - } - } - FinalState { - id: finalState - } - } - - signal mysignal(string mystr, bool mybool, int myint) - - name: "testTriggeredArguments2" - function test_triggeredArguments() - { - tryCompare(startState, "active", true) - - // Emit the signalTrans.signal - testCase.mysignal("test1", true, 2) - compare(testCase.mystr, "test1") - compare(testCase.mybool, true) - compare(testCase.myint, 2) - } -} |