summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--examples/examples.pro6
-rw-r--r--examples/trafficlight-common/Light.qml (renamed from examples/trafficlight-qml/Light.qml)0
-rw-r--r--examples/trafficlight-common/statemachine.scxml (renamed from examples/trafficlight-qml/statemachine.scxml)0
-rw-r--r--examples/trafficlight-common/trafficlight.cpp (renamed from examples/trafficlight-widgets/trafficlight.cpp)73
-rw-r--r--examples/trafficlight-common/trafficlight.h76
-rw-r--r--examples/trafficlight-qml-dynamic/trafficlight-qml-dynamic.cpp (renamed from examples/trafficlight-widgets/trafficlight.h)20
-rw-r--r--examples/trafficlight-qml-dynamic/trafficlight-qml-dynamic.pro13
-rw-r--r--examples/trafficlight-qml-dynamic/trafficlight-qml-dynamic.qml103
-rw-r--r--examples/trafficlight-qml-dynamic/trafficlight-qml-dynamic.qrc7
-rw-r--r--examples/trafficlight-qml-static/trafficlight-dynamic.qml (renamed from examples/trafficlight-qml/trafficlight-dynamic.qml)0
-rw-r--r--examples/trafficlight-qml-static/trafficlight-qml-dynamic.qmlproject (renamed from examples/trafficlight-qml/trafficlight-qml-dynamic.qmlproject)0
-rw-r--r--examples/trafficlight-qml-static/trafficlight-qml-static.cpp (renamed from examples/trafficlight-qml/trafficlight-qml-static.cpp)0
-rw-r--r--examples/trafficlight-qml-static/trafficlight-qml-static.pro15
-rw-r--r--examples/trafficlight-qml-static/trafficlight-qml-static.qml (renamed from examples/trafficlight-qml/trafficlight-qml-static.qml)0
-rw-r--r--examples/trafficlight-qml-static/trafficlight-qml-static.qrc (renamed from examples/trafficlight-qml/trafficlight-qml-static.qrc)2
-rw-r--r--examples/trafficlight-qml/trafficlight-qml-static.pro18
-rw-r--r--examples/trafficlight-qml/trafficlight-qml.pro3
-rw-r--r--examples/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.cpp (renamed from examples/trafficlight-widgets/trafficlight-dynamic.cpp)2
-rw-r--r--examples/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.pro15
-rw-r--r--examples/trafficlight-widgets-static/trafficlight-widgets-static.cpp (renamed from examples/trafficlight-widgets/trafficlight-static.cpp)2
-rw-r--r--examples/trafficlight-widgets-static/trafficlight-widgets-static.pro13
-rw-r--r--examples/trafficlight-widgets/statemachine.scxml39
-rw-r--r--examples/trafficlight-widgets/trafficlight-widgets-dynamic.pro11
-rw-r--r--examples/trafficlight-widgets/trafficlight-widgets-static.pro11
-rw-r--r--examples/trafficlight-widgets/trafficlight-widgets.pro2
-rw-r--r--mkspecs/features/qscxmlc.prf (renamed from mkspecs/features/qscxmlcpp.prf)0
-rw-r--r--scxml-tools.pro3
-rw-r--r--src/imports/imports.pro3
-rw-r--r--src/imports/scxmlstatemachine/plugin.cpp (renamed from src/imports/plugin.cpp)0
-rw-r--r--src/imports/scxmlstatemachine/qmldir (renamed from src/imports/qmldir)0
-rw-r--r--src/imports/scxmlstatemachine/scxmlstatemachine.pro (renamed from src/imports/qml-module.pro)0
-rw-r--r--src/imports/scxmlstatemachine/signalevent.cpp (renamed from src/imports/signalevent.cpp)0
-rw-r--r--src/imports/scxmlstatemachine/signalevent.h (renamed from src/imports/signalevent.h)0
-rw-r--r--src/imports/scxmlstatemachine/state.cpp (renamed from src/imports/state.cpp)0
-rw-r--r--src/imports/scxmlstatemachine/state.h (renamed from src/imports/state.h)0
-rw-r--r--src/imports/scxmlstatemachine/statemachine.cpp (renamed from src/imports/statemachine.cpp)30
-rw-r--r--src/imports/scxmlstatemachine/statemachine.h (renamed from src/imports/statemachine.h)11
-rw-r--r--tests/auto/auto.pro3
-rw-r--r--tests/tests.pro3
-rw-r--r--tools/tools.pro2
41 files changed, 324 insertions, 164 deletions
diff --git a/.gitignore b/.gitignore
index 7be1abf..ce475a4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,7 +10,7 @@ Makefile
moc_*.cpp
*.dylib
*.moc
-/src/qscxmlcpp/qscxmlcpp
+/tools/qscxmlc/qscxmlc
/tests/testCpp/testCpp
tst_cppgen
diff --git a/examples/examples.pro b/examples/examples.pro
index 16142fc..1242e81 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -1,9 +1,11 @@
TEMPLATE = subdirs
qtHaveModule(widgets) {
- SUBDIRS += trafficlight-widgets
+ SUBDIRS += trafficlight-widgets-static
+ SUBDIRS += trafficlight-widgets-dynamic
}
qtHaveModule(qml) {
- SUBDIRS += trafficlight-qml
+ SUBDIRS += trafficlight-qml-static
+ SUBDIRS += trafficlight-qml-dynamic
}
diff --git a/examples/trafficlight-qml/Light.qml b/examples/trafficlight-common/Light.qml
index 94904fc..94904fc 100644
--- a/examples/trafficlight-qml/Light.qml
+++ b/examples/trafficlight-common/Light.qml
diff --git a/examples/trafficlight-qml/statemachine.scxml b/examples/trafficlight-common/statemachine.scxml
index 02d9eb8..02d9eb8 100644
--- a/examples/trafficlight-qml/statemachine.scxml
+++ b/examples/trafficlight-common/statemachine.scxml
diff --git a/examples/trafficlight-widgets/trafficlight.cpp b/examples/trafficlight-common/trafficlight.cpp
index afd2b68..c7ce301 100644
--- a/examples/trafficlight-widgets/trafficlight.cpp
+++ b/examples/trafficlight-common/trafficlight.cpp
@@ -42,43 +42,6 @@
#include <QtWidgets>
-class LightWidget : public QWidget
-{
- Q_OBJECT
- Q_PROPERTY(bool on READ isOn WRITE setOn)
-public:
- LightWidget(const QColor &color, QWidget *parent = 0)
- : QWidget(parent), m_color(color), m_on(false) {}
-
- bool isOn() const
- { return m_on; }
- void setOn(bool on)
- {
- if (on == m_on)
- return;
- m_on = on;
- update();
- }
-
-public slots:
- void switchLight(bool onoff) { setOn(onoff); }
-
-protected:
- virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE
- {
- if (!m_on)
- return;
- QPainter painter(this);
- painter.setRenderHint(QPainter::Antialiasing);
- painter.setBrush(m_color);
- painter.drawEllipse(0, 0, width(), height());
- }
-
-private:
- QColor m_color;
- bool m_on;
-};
-
class TrafficLightWidget : public QWidget
{
public:
@@ -99,11 +62,11 @@ public:
}
LightWidget *redLight() const
- { return m_red; }
+ { return m_red; }
LightWidget *yellowLight() const
- { return m_yellow; }
+ { return m_yellow; }
LightWidget *greenLight() const
- { return m_green; }
+ { return m_green; }
private:
LightWidget *m_red;
@@ -133,4 +96,32 @@ TrafficLight::TrafficLight(Scxml::StateTable *machine, QWidget *parent)
machine->start();
}
-#include "trafficlight.moc"
+LightWidget::LightWidget(const QColor &color, QWidget *parent)
+ : QWidget(parent)
+ , m_color(color)
+ , m_on(false)
+{}
+
+bool LightWidget::isOn() const
+{ return m_on; }
+
+void LightWidget::setOn(bool on)
+{
+ if (on == m_on)
+ return;
+ m_on = on;
+ update();
+}
+
+void LightWidget::switchLight(bool onoff)
+{ setOn(onoff); }
+
+void LightWidget::paintEvent(QPaintEvent *)
+{
+ if (!m_on)
+ return;
+ QPainter painter(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.setBrush(m_color);
+ painter.drawEllipse(0, 0, width(), height());
+}
diff --git a/examples/trafficlight-common/trafficlight.h b/examples/trafficlight-common/trafficlight.h
new file mode 100644
index 0000000..bb475ea
--- /dev/null
+++ b/examples/trafficlight-common/trafficlight.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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$
+**
+****************************************************************************/
+
+#ifndef TRAFFICLIGHT_H
+#define TRAFFICLIGHT_H
+
+#include <QScxml/scxmlstatetable.h>
+
+#include <QWidget>
+
+class TrafficLight : public QWidget
+{
+public:
+ TrafficLight(Scxml::StateTable *machine, QWidget *parent = 0);
+};
+
+class LightWidget: public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(bool on READ isOn WRITE setOn)
+
+public:
+ LightWidget(const QColor &color, QWidget *parent = 0);
+
+ bool isOn() const;
+ void setOn(bool on);
+
+public slots:
+ void switchLight(bool onoff);
+
+protected:
+ virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+
+private:
+ QColor m_color;
+ bool m_on;
+};
+
+#endif // TRAFFICLIGHT_H
diff --git a/examples/trafficlight-widgets/trafficlight.h b/examples/trafficlight-qml-dynamic/trafficlight-qml-dynamic.cpp
index df807aa..59eb183 100644
--- a/examples/trafficlight-widgets/trafficlight.h
+++ b/examples/trafficlight-qml-dynamic/trafficlight-qml-dynamic.cpp
@@ -38,17 +38,17 @@
**
****************************************************************************/
-#ifndef TRAFFICLIGHT_H
-#define TRAFFICLIGHT_H
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+#include <QQmlContext>
-#include <QScxml/scxmlstatetable.h>
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
-#include <QWidget>
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:///trafficlight-qml-dynamic.qml")));
-class TrafficLight : public QWidget
-{
-public:
- TrafficLight(Scxml::StateTable *machine, QWidget *parent = 0);
-};
+ return app.exec();
+}
-#endif // TRAFFICLIGHT_H
diff --git a/examples/trafficlight-qml-dynamic/trafficlight-qml-dynamic.pro b/examples/trafficlight-qml-dynamic/trafficlight-qml-dynamic.pro
new file mode 100644
index 0000000..6a11de5
--- /dev/null
+++ b/examples/trafficlight-qml-dynamic/trafficlight-qml-dynamic.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+
+QT += qml qscxml
+
+SOURCES += trafficlight-qml-dynamic.cpp
+
+RESOURCES += trafficlight-qml-dynamic.qrc
+
+load(qscxmlc)
+
+target.path = $$[QT_INSTALL_EXAMPLES]/scxml/trafficlight-qml-dynamic
+INSTALLS += target
+
diff --git a/examples/trafficlight-qml-dynamic/trafficlight-qml-dynamic.qml b/examples/trafficlight-qml-dynamic/trafficlight-qml-dynamic.qml
new file mode 100644
index 0000000..b178384
--- /dev/null
+++ b/examples/trafficlight-qml-dynamic/trafficlight-qml-dynamic.qml
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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.5
+import QtQuick.Window 2.2
+import Scxml 1.0 as Scxml
+
+Window {
+ visible: true
+ width: 100
+ height: 300
+ color: "black"
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ Qt.quit();
+ }
+ }
+
+ Light {
+ id: redLight
+ anchors.top: parent.top
+ color: "red"
+ visible: red.active || redGoingGreen.active
+ }
+
+ Light {
+ id: yellowLight
+ anchors.top: redLight.bottom
+ color: "yellow"
+ visible: yellow.active
+ }
+
+ Light {
+ id: greenLight
+ anchors.top: yellowLight.bottom
+ color: "green"
+ visible: green.active
+ }
+
+ Scxml.StateMachine {
+ filename: "qrc:///statemachine.scxml"
+
+ Scxml.State {
+ id: red
+ scxmlName: "red"
+ }
+
+ Scxml.State {
+ id: yellow
+ scxmlName: "yellow"
+ }
+
+ Scxml.State {
+ id: redGoingGreen
+ scxmlName: "red-going-green"
+ }
+
+ Scxml.State {
+ id: green
+ scxmlName: "green"
+ }
+ }
+}
+
diff --git a/examples/trafficlight-qml-dynamic/trafficlight-qml-dynamic.qrc b/examples/trafficlight-qml-dynamic/trafficlight-qml-dynamic.qrc
new file mode 100644
index 0000000..b4bcaec
--- /dev/null
+++ b/examples/trafficlight-qml-dynamic/trafficlight-qml-dynamic.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file alias="Light.qml">../trafficlight-common/Light.qml</file>
+ <file>trafficlight-qml-dynamic.qml</file>
+ <file alias="statemachine.scxml">../trafficlight-common/statemachine.scxml</file>
+ </qresource>
+</RCC>
diff --git a/examples/trafficlight-qml/trafficlight-dynamic.qml b/examples/trafficlight-qml-static/trafficlight-dynamic.qml
index 4bfc9fc..4bfc9fc 100644
--- a/examples/trafficlight-qml/trafficlight-dynamic.qml
+++ b/examples/trafficlight-qml-static/trafficlight-dynamic.qml
diff --git a/examples/trafficlight-qml/trafficlight-qml-dynamic.qmlproject b/examples/trafficlight-qml-static/trafficlight-qml-dynamic.qmlproject
index 5f06f00..5f06f00 100644
--- a/examples/trafficlight-qml/trafficlight-qml-dynamic.qmlproject
+++ b/examples/trafficlight-qml-static/trafficlight-qml-dynamic.qmlproject
diff --git a/examples/trafficlight-qml/trafficlight-qml-static.cpp b/examples/trafficlight-qml-static/trafficlight-qml-static.cpp
index 1a3c838..1a3c838 100644
--- a/examples/trafficlight-qml/trafficlight-qml-static.cpp
+++ b/examples/trafficlight-qml-static/trafficlight-qml-static.cpp
diff --git a/examples/trafficlight-qml-static/trafficlight-qml-static.pro b/examples/trafficlight-qml-static/trafficlight-qml-static.pro
new file mode 100644
index 0000000..8841abf
--- /dev/null
+++ b/examples/trafficlight-qml-static/trafficlight-qml-static.pro
@@ -0,0 +1,15 @@
+TEMPLATE = app
+
+QT += qml qscxml
+
+SOURCES += trafficlight-qml-static.cpp
+
+RESOURCES += trafficlight-qml-static.qrc
+
+STATECHARTS = ../trafficlight-common/statemachine.scxml
+
+load(qscxmlc)
+
+target.path = $$[QT_INSTALL_EXAMPLES]/scxml/trafficlight-qml-static
+INSTALLS += target
+
diff --git a/examples/trafficlight-qml/trafficlight-qml-static.qml b/examples/trafficlight-qml-static/trafficlight-qml-static.qml
index 92a9d9a..92a9d9a 100644
--- a/examples/trafficlight-qml/trafficlight-qml-static.qml
+++ b/examples/trafficlight-qml-static/trafficlight-qml-static.qml
diff --git a/examples/trafficlight-qml/trafficlight-qml-static.qrc b/examples/trafficlight-qml-static/trafficlight-qml-static.qrc
index f7fc3f5..4d1051d 100644
--- a/examples/trafficlight-qml/trafficlight-qml-static.qrc
+++ b/examples/trafficlight-qml-static/trafficlight-qml-static.qrc
@@ -1,6 +1,6 @@
<RCC>
<qresource prefix="/">
<file>trafficlight-qml-static.qml</file>
- <file>Light.qml</file>
+ <file alias="Light.qml">../trafficlight-common/Light.qml</file>
</qresource>
</RCC>
diff --git a/examples/trafficlight-qml/trafficlight-qml-static.pro b/examples/trafficlight-qml/trafficlight-qml-static.pro
deleted file mode 100644
index 66d759e..0000000
--- a/examples/trafficlight-qml/trafficlight-qml-static.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-TEMPLATE = app
-
-QT += qml qscxml
-
-SOURCES += trafficlight-qml-static.cpp
-
-RESOURCES += trafficlight-qml-static.qrc
-
-STATECHARTS = statemachine.scxml
-
-load(qscxmlcpp)
-
-# Additional import path used to resolve QML modules in Qt Creator's code model
-QML_IMPORT_PATH =
-
-target.path = $$[QT_INSTALL_EXAMPLES]/scxml/trafficlight-widgets
-INSTALLS += target
-
diff --git a/examples/trafficlight-qml/trafficlight-qml.pro b/examples/trafficlight-qml/trafficlight-qml.pro
deleted file mode 100644
index 0a1197e..0000000
--- a/examples/trafficlight-qml/trafficlight-qml.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-TEMPLATE = subdirs
-OTHER_FILES += trafficlight-qml-dynamic.qmlproject
-SUBDIRS = trafficlight-qml-static.pro
diff --git a/examples/trafficlight-widgets/trafficlight-dynamic.cpp b/examples/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.cpp
index a62514b..f9fa604 100644
--- a/examples/trafficlight-widgets/trafficlight-dynamic.cpp
+++ b/examples/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include "trafficlight.h"
+#include "../trafficlight-common/trafficlight.h"
#include <QScxml/scxmlparser.h>
diff --git a/examples/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.pro b/examples/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.pro
new file mode 100644
index 0000000..a6f2c0b
--- /dev/null
+++ b/examples/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.pro
@@ -0,0 +1,15 @@
+QT += widgets qscxml
+
+SOURCES = ../trafficlight-common/trafficlight.cpp
+HEADERS = ../trafficlight-common/trafficlight.h
+
+SOURCES += trafficlight-widgets-dynamic.cpp
+
+DEFINES += "\"WORKING_DIR=\\\"$${PWD}\\\"\""
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/scxml/trafficlights-widgets-dynamic
+target.files += statemachine.scxml
+INSTALLS += target
+
+load(qscxmlc)
diff --git a/examples/trafficlight-widgets/trafficlight-static.cpp b/examples/trafficlight-widgets-static/trafficlight-widgets-static.cpp
index f752151..dfbfa89 100644
--- a/examples/trafficlight-widgets/trafficlight-static.cpp
+++ b/examples/trafficlight-widgets-static/trafficlight-widgets-static.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
#include "statemachine.h"
-#include "trafficlight.h"
+#include "../trafficlight-common/trafficlight.h"
#include <QApplication>
diff --git a/examples/trafficlight-widgets-static/trafficlight-widgets-static.pro b/examples/trafficlight-widgets-static/trafficlight-widgets-static.pro
new file mode 100644
index 0000000..d8a020d
--- /dev/null
+++ b/examples/trafficlight-widgets-static/trafficlight-widgets-static.pro
@@ -0,0 +1,13 @@
+QT += widgets qscxml
+
+SOURCES = ../trafficlight-common/trafficlight.cpp
+HEADERS = ../trafficlight-common/trafficlight.h
+STATECHARTS = ../trafficlight-common/statemachine.scxml
+
+SOURCES += trafficlight-widgets-static.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/scxml/trafficlight-widgets-static
+INSTALLS += target
+
+load(qscxmlc)
diff --git a/examples/trafficlight-widgets/statemachine.scxml b/examples/trafficlight-widgets/statemachine.scxml
deleted file mode 100644
index 7955b7c..0000000
--- a/examples/trafficlight-widgets/statemachine.scxml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<scxml
- xmlns="http://www.w3.org/2005/07/scxml"
- xmlns:qt="http://theqtcompany.com/scxml/2015/06/"
- version="1.0"
- name="trafficlight"
- qt:classname="TrafficLightStateMachine"
- initial="red"
->
- <state id="red">
- <onentry>
- <send event="start-going-green" delay="3s"/>
- </onentry>
- <transition event="start-going-green" target="red-going-green"/>
- </state>
-
- <state id="yellow">
- <state id="red-going-green">
- <onentry>
- <send event="go-green" delay="1s"/>
- </onentry>
- <transition event="go-green" target="green"/>
- </state>
-
- <state id="green-going-red">
- <onentry>
- <send event="go-red" delay="1s"/>
- </onentry>
- <transition event="go-red" target="red"/>
- </state>
- </state>
-
- <state id="green">
- <onentry>
- <send event="start-going-red" delay="3s"/>
- </onentry>
- <transition event="start-going-red" target="green-going-red"/>
- </state>
-</scxml>
diff --git a/examples/trafficlight-widgets/trafficlight-widgets-dynamic.pro b/examples/trafficlight-widgets/trafficlight-widgets-dynamic.pro
deleted file mode 100644
index 820e8d7..0000000
--- a/examples/trafficlight-widgets/trafficlight-widgets-dynamic.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-QT += widgets qscxml
-
-SOURCES = trafficlight.cpp trafficlight.h trafficlight-dynamic.cpp
-
-DEFINES += "\"WORKING_DIR=\\\"$${PWD}\\\"\""
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/scxml/trafficlight-widgets
-INSTALLS += target statemachine.scxml
-
-load(qscxmlcpp)
diff --git a/examples/trafficlight-widgets/trafficlight-widgets-static.pro b/examples/trafficlight-widgets/trafficlight-widgets-static.pro
deleted file mode 100644
index c3141f0..0000000
--- a/examples/trafficlight-widgets/trafficlight-widgets-static.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-QT += widgets qscxml
-
-SOURCES = trafficlight.cpp trafficlight.h trafficlight-static.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/scxml/trafficlight-widgets
-INSTALLS += target
-
-STATECHARTS = statemachine.scxml
-
-load(qscxmlcpp)
diff --git a/examples/trafficlight-widgets/trafficlight-widgets.pro b/examples/trafficlight-widgets/trafficlight-widgets.pro
deleted file mode 100644
index d7a25b9..0000000
--- a/examples/trafficlight-widgets/trafficlight-widgets.pro
+++ /dev/null
@@ -1,2 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = trafficlight-widgets-static.pro trafficlight-widgets-dynamic.pro
diff --git a/mkspecs/features/qscxmlcpp.prf b/mkspecs/features/qscxmlc.prf
index c8ae80b..c8ae80b 100644
--- a/mkspecs/features/qscxmlcpp.prf
+++ b/mkspecs/features/qscxmlc.prf
diff --git a/scxml-tools.pro b/scxml-tools.pro
index 0f3c8f5..ebf69e6 100644
--- a/scxml-tools.pro
+++ b/scxml-tools.pro
@@ -1,7 +1,6 @@
CONFIG += tests_need_tools examples_need_tools
-FEATURES += \
- mkspecs/features/qscxmlcpp.prf
+FEATURES += mkspecs/features/qscxmlc.prf
features.files = $$FEATURES
features.path = $$[QT_HOST_DATA]/mkspecs/features/
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
new file mode 100644
index 0000000..60a0bd2
--- /dev/null
+++ b/src/imports/imports.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+SUBDIRS = scxmlstatemachine
+
diff --git a/src/imports/plugin.cpp b/src/imports/scxmlstatemachine/plugin.cpp
index 9b2f4d4..9b2f4d4 100644
--- a/src/imports/plugin.cpp
+++ b/src/imports/scxmlstatemachine/plugin.cpp
diff --git a/src/imports/qmldir b/src/imports/scxmlstatemachine/qmldir
index a411f70..a411f70 100644
--- a/src/imports/qmldir
+++ b/src/imports/scxmlstatemachine/qmldir
diff --git a/src/imports/qml-module.pro b/src/imports/scxmlstatemachine/scxmlstatemachine.pro
index 4cbf853..4cbf853 100644
--- a/src/imports/qml-module.pro
+++ b/src/imports/scxmlstatemachine/scxmlstatemachine.pro
diff --git a/src/imports/signalevent.cpp b/src/imports/scxmlstatemachine/signalevent.cpp
index a9c3739..a9c3739 100644
--- a/src/imports/signalevent.cpp
+++ b/src/imports/scxmlstatemachine/signalevent.cpp
diff --git a/src/imports/signalevent.h b/src/imports/scxmlstatemachine/signalevent.h
index 473fc35..473fc35 100644
--- a/src/imports/signalevent.h
+++ b/src/imports/scxmlstatemachine/signalevent.h
diff --git a/src/imports/state.cpp b/src/imports/scxmlstatemachine/state.cpp
index da240b4..da240b4 100644
--- a/src/imports/state.cpp
+++ b/src/imports/scxmlstatemachine/state.cpp
diff --git a/src/imports/state.h b/src/imports/scxmlstatemachine/state.h
index 53c3e37..53c3e37 100644
--- a/src/imports/state.h
+++ b/src/imports/scxmlstatemachine/state.h
diff --git a/src/imports/statemachine.cpp b/src/imports/scxmlstatemachine/statemachine.cpp
index 2adec4c..c953018 100644
--- a/src/imports/statemachine.cpp
+++ b/src/imports/scxmlstatemachine/statemachine.cpp
@@ -26,7 +26,8 @@
#include <QQmlContext>
#include <QQmlEngine>
#include <QQmlInfo>
-#include <QFile>
+#include <QQmlFile>
+#include <QBuffer>
static void append(QQmlListProperty<QObject> *prop, QObject *o)
{
@@ -101,14 +102,14 @@ void StateMachine::setStateMachine(Scxml::StateTable *table)
}
}
-QString StateMachine::filename()
+QUrl StateMachine::filename()
{
return m_filename;
}
-void StateMachine::setFilename(const QString filename)
+void StateMachine::setFilename(const QUrl &filename)
{
- QString oldFilename = m_filename;
+ QUrl oldFilename = m_filename;
if (m_table) {
delete m_table;
m_table = nullptr;
@@ -125,22 +126,29 @@ void StateMachine::setFilename(const QString filename)
}
}
-bool StateMachine::parse(const QString &filename)
+bool StateMachine::parse(const QUrl &filename)
{
- QFile scxmlFile(filename);
- if (!scxmlFile.open(QIODevice::ReadOnly)) {
- qmlInfo(this) << QStringLiteral("ERROR: cannot open '%1' for reading!").arg(filename);
+ if (!QQmlFile::isSynchronous(filename)) {
+ qmlInfo(this) << QStringLiteral("ERROR: cannot open '%1' for reading: only synchronous file access is supported.").arg(filename.fileName());
+ return false;
+ }
+ QQmlFile scxmlFile(QQmlEngine::contextForObject(this)->engine(), filename);
+ if (scxmlFile.isError()) {
+ // the synchronous case can only fail when the file is not found (or not readable).
+ qmlInfo(this) << QStringLiteral("ERROR: cannot open '%1' for reading.").arg(filename.fileName());
return false;
}
- QXmlStreamReader xmlReader(&scxmlFile);
+ QByteArray data(scxmlFile.dataByteArray());
+ QBuffer buf(&data);
+ Q_ASSERT(buf.open(QIODevice::ReadOnly));
+ QXmlStreamReader xmlReader(&buf);
Scxml::ScxmlParser parser(&xmlReader);
parser.parse();
- scxmlFile.close();
setStateMachine(parser.table());
if (parser.state() != Scxml::ScxmlParser::FinishedParsing || m_table == nullptr) {
- qmlInfo(this) << QStringLiteral("Something went wrong while parsing '%1':").arg(filename) << endl;
+ qmlInfo(this) << QStringLiteral("Something went wrong while parsing '%1':").arg(filename.fileName()) << endl;
foreach (const Scxml::ErrorMessage &msg, parser.errors()) {
qmlInfo(this) << msg.fileName << QStringLiteral(":") << msg.line
<< QStringLiteral(":") << msg.column
diff --git a/src/imports/statemachine.h b/src/imports/scxmlstatemachine/statemachine.h
index a192a32..554e25d 100644
--- a/src/imports/statemachine.h
+++ b/src/imports/scxmlstatemachine/statemachine.h
@@ -19,6 +19,7 @@
#ifndef STATEMACHINE_H
#define STATEMACHINE_H
+#include <QUrl>
#include <QVector>
#include <QQmlParserStatus>
#include <QQmlListProperty>
@@ -33,7 +34,7 @@ class StateMachine: public QObject, public QQmlParserStatus
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QQmlListProperty<QObject> states READ states NOTIFY statesChanged DESIGNABLE false)
- Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged)
+ Q_PROPERTY(QUrl filename READ filename WRITE setFilename NOTIFY filenameChanged)
Q_PROPERTY(Scxml::StateTable* stateMachine READ stateMachine WRITE setStateMachine)
Q_CLASSINFO("DefaultProperty", "states")
@@ -49,18 +50,18 @@ public:
Scxml::StateTable *stateMachine() const;
void setStateMachine(Scxml::StateTable *stateMachine);
- QString filename();
- void setFilename(const QString filename);
+ QUrl filename();
+ void setFilename(const QUrl &filename);
Q_SIGNALS:
void statesChanged();
void filenameChanged();
private:
- bool parse(const QString &filename);
+ bool parse(const QUrl &filename);
private:
- QString m_filename;
+ QUrl m_filename;
Kids m_children;
Scxml::StateTable *m_table = nullptr;
};
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 3f07fe7..c002d4d 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -1,3 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS += cmake scion
-
+SUBDIRS = cmake scion
diff --git a/tests/tests.pro b/tests/tests.pro
index 175513a..378f017 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -2,5 +2,4 @@ TEMPLATE = subdirs
CONFIG += no_docs_target
SUBDIRS += \
- auto \
- manual
+ auto
diff --git a/tools/tools.pro b/tools/tools.pro
index 315133a..1854cfc 100644
--- a/tools/tools.pro
+++ b/tools/tools.pro
@@ -1,2 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS += qscxmlc
+SUBDIRS = qscxmlc