From ae36d94c2f385e272ae25fcd0fe780edb70cf7d9 Mon Sep 17 00:00:00 2001 From: Karsten Heimrich Date: Fri, 14 Aug 2020 13:04:22 +0200 Subject: Remove qml statemachine plugin from qtdeclarative Task-number: QTBUG-80316 Change-Id: I584b699a1eec88117f343870bd2cd01075da64f7 Reviewed-by: Maurice Kalinowski --- src/imports/CMakeLists.txt | 3 - src/imports/imports.pro | 1 - src/imports/statemachine/CMakeLists.txt | 30 --- src/imports/statemachine/childrenprivate.h | 188 ------------- src/imports/statemachine/finalstate.cpp | 85 ------ src/imports/statemachine/finalstate.h | 74 ------ src/imports/statemachine/plugin.cpp | 70 ----- src/imports/statemachine/qmldir | 4 - src/imports/statemachine/signaltransition.cpp | 349 ------------------------- src/imports/statemachine/signaltransition.h | 115 -------- src/imports/statemachine/state.cpp | 240 ----------------- src/imports/statemachine/state.h | 78 ------ src/imports/statemachine/statemachine.cpp | 234 ----------------- src/imports/statemachine/statemachine.h | 93 ------- src/imports/statemachine/statemachine.pro | 27 -- src/imports/statemachine/statemachineforeign.h | 84 ------ src/imports/statemachine/timeouttransition.cpp | 114 -------- src/imports/statemachine/timeouttransition.h | 77 ------ 18 files changed, 1866 deletions(-) delete mode 100644 src/imports/statemachine/CMakeLists.txt delete mode 100644 src/imports/statemachine/childrenprivate.h delete mode 100644 src/imports/statemachine/finalstate.cpp delete mode 100644 src/imports/statemachine/finalstate.h delete mode 100644 src/imports/statemachine/plugin.cpp delete mode 100644 src/imports/statemachine/qmldir delete mode 100644 src/imports/statemachine/signaltransition.cpp delete mode 100644 src/imports/statemachine/signaltransition.h delete mode 100644 src/imports/statemachine/state.cpp delete mode 100644 src/imports/statemachine/state.h delete mode 100644 src/imports/statemachine/statemachine.cpp delete mode 100644 src/imports/statemachine/statemachine.h delete mode 100644 src/imports/statemachine/statemachine.pro delete mode 100644 src/imports/statemachine/statemachineforeign.h delete mode 100644 src/imports/statemachine/timeouttransition.cpp delete mode 100644 src/imports/statemachine/timeouttransition.h (limited to 'src/imports') 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:: -# 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 -#include -#include -#include -#include - -enum class ChildrenMode { - None = 0x0, - State = 0x1, - Transition = 0x2, - StateOrTransition = State | Transition -}; - -template -static T *parentObject(QQmlListProperty *prop) { return static_cast(prop->object); } - -template -struct ParentHandler -{ - static bool unparentItem(QQmlListProperty *prop, QObject *oldItem); - static bool parentItem(QQmlListProperty *prop, QObject *item); -}; - -template -struct ParentHandler -{ - static bool unparentItem(QQmlListProperty *, QObject *) { return true; } - static bool parentItem(QQmlListProperty *, QObject *) { return true; } -}; - -template -struct ParentHandler -{ - static bool parentItem(QQmlListProperty *prop, QObject *item) - { - if (QAbstractState *state = qobject_cast(item)) { - state->setParent(parentObject(prop)); - return true; - } - return false; - } - - static bool unparentItem(QQmlListProperty *, QObject *oldItem) - { - if (QAbstractState *state = qobject_cast(oldItem)) { - state->setParent(nullptr); - return true; - } - return false; - } -}; - -template -struct ParentHandler -{ - static bool parentItem(QQmlListProperty *prop, QObject *item) - { - if (QAbstractTransition *trans = qobject_cast(item)) { - parentObject(prop)->addTransition(trans); - return true; - } - return false; - } - - static bool unparentItem(QQmlListProperty *prop, QObject *oldItem) - { - if (QAbstractTransition *trans = qobject_cast(oldItem)) { - parentObject(prop)->removeTransition(trans); - return true; - } - return false; - } -}; - -template -struct ParentHandler -{ - static bool parentItem(QQmlListProperty *prop, QObject *oldItem) - { - return ParentHandler::parentItem(prop, oldItem) - || ParentHandler::parentItem(prop, oldItem); - } - - static bool unparentItem(QQmlListProperty *prop, QObject *oldItem) - { - return ParentHandler::unparentItem(prop, oldItem) - || ParentHandler::unparentItem(prop, oldItem); - } -}; - -template -class ChildrenPrivate -{ -public: - static void append(QQmlListProperty *prop, QObject *item) - { - Handler::parentItem(prop, item); - static_cast(prop->data)->children.append(item); - emit parentObject(prop)->childrenChanged(); - } - - static int count(QQmlListProperty *prop) - { - return static_cast(prop->data)->children.count(); - } - - static QObject *at(QQmlListProperty *prop, int index) - { - return static_cast(prop->data)->children.at(index); - } - - static void clear(QQmlListProperty *prop) - { - auto &children = static_cast(prop->data)->children; - for (QObject *oldItem : qAsConst(children)) - Handler::unparentItem(prop, oldItem); - - children.clear(); - emit parentObject(prop)->childrenChanged(); - } - - static void replace(QQmlListProperty *prop, int index, QObject *item) - { - auto &children = static_cast(prop->data)->children; - - Handler::unparentItem(prop, children.at(index)); - Handler::parentItem(prop, item); - - children.replace(index, item); - emit parentObject(prop)->childrenChanged(); - } - - static void removeLast(QQmlListProperty *prop) - { - Handler::unparentItem(prop, static_cast(prop->data)->children.takeLast()); - emit parentObject(prop)->childrenChanged(); - } - -private: - using Self = ChildrenPrivate; - using Handler = ParentHandler; - - QList 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 -#include -#include - -FinalState::FinalState(QState *parent) - : QFinalState(parent) -{ -} - -QQmlListProperty FinalState::children() -{ - return QQmlListProperty(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 -#include -#include - - -QT_BEGIN_NAMESPACE - -class FinalState : public QFinalState -{ - Q_OBJECT - Q_PROPERTY(QQmlListProperty children READ children NOTIFY childrenChanged) - Q_CLASSINFO("DefaultProperty", "children") - QML_ELEMENT - QML_ADDED_IN_VERSION(1, 0) - -public: - explicit FinalState(QState *parent = 0); - - QQmlListProperty children(); - -Q_SIGNALS: - void childrenChanged(); - -private: - ChildrenPrivate 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 -#include -#include - -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 -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -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(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(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()) { - sender = signalSlot->object(); - Q_ASSERT(sender); - signalMethod = sender->metaObject()->method(signalSlot->methodIndex()); - } else if (QV4::QmlSignalHandler *signalObject = value->as()) { // 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 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 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 expression( - new QQmlBoundSignalExpression(target, signalIndex, ctxtdata, this, f), - QQmlRefPointer::Adopt); - expression->setNotifyOnValueChanged(false); - m_signalExpression = expression; - } else { - m_signalExpression.adopt(nullptr); - } -} - -void SignalTransitionParser::verifyBindings(const QQmlRefPointer &compilationUnit, const QList &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 &compilationUnit, - const QList &bindings) -{ - SignalTransition *st = qobject_cast(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 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 -#include -#include - -#include -#include -#include -#include -#include - -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 m_compilationUnit; - QList m_bindings; - QQmlRefPointer m_signalExpression; -}; - -class SignalTransitionParser : public QQmlCustomParser -{ -public: - void verifyBindings(const QQmlRefPointer &compilationUnit, const QList &props) override; - void applyBindings(QObject *object, const QQmlRefPointer &compilationUnit, const QList &bindings) override; -}; - -template<> -inline QQmlCustomParser *qmlCreateCustomParser() -{ - 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 -#include -#include - -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 State::children() -{ - return QQmlListProperty(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 -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class State : public QState, public QQmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QQmlListProperty 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 children(); - -Q_SIGNALS: - void childrenChanged(); - -private: - ChildrenPrivate 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 -#include -#include -#include - -#include -#include - -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 StateMachine::children() -{ - return QQmlListProperty(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 -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class StateMachine : public QStateMachine, public QQmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QQmlListProperty 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 children(); - - bool isRunning() const; - void setRunning(bool running); - -private Q_SLOTS: - void checkChildMode(); - -Q_SIGNALS: - void childrenChanged(); - /*! - * \internal - */ - void qmlRunningChanged(); - -private: - ChildrenPrivate 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 -#include -#include -#include -#include - -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 -#include -#include - -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(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 -#include -#include - -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 -- cgit v1.2.3