summaryrefslogtreecommitdiffstats
path: root/qmlscxml/qmlscxml.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qmlscxml/qmlscxml.cpp')
-rw-r--r--qmlscxml/qmlscxml.cpp45
1 files changed, 36 insertions, 9 deletions
diff --git a/qmlscxml/qmlscxml.cpp b/qmlscxml/qmlscxml.cpp
index 04a4c89..367fff1 100644
--- a/qmlscxml/qmlscxml.cpp
+++ b/qmlscxml/qmlscxml.cpp
@@ -41,6 +41,7 @@
#include "qmlscxml.h"
#include "qscxml.h"
#include <QDebug>
+#include <QTimer>
#include "qmlpropertymap.h"
class QmlScxmlEventProxy : public QObject
@@ -61,7 +62,9 @@ class QmlScxmlEventProxy : public QObject
public Q_SLOTS:
void raise()
{
- scxml->postNamedEvent(eventName);
+ if (scxml) {
+ scxml->postDelayedEvent(new QScxmlEvent(eventName),0);
+ }
}
void onEvent(const QString & e)
@@ -122,7 +125,6 @@ namespace {
};
void QmlScxml::setSource(const QUrl & u)
{
- qDebug() << u;
if (u != m_source) {
m_source = u;
if (scxml) {
@@ -135,6 +137,7 @@ void QmlScxml::setSource(const QUrl & u)
connect(scxml,SIGNAL(stopped()),this,SIGNAL(runningChanged()));
connect(scxml,SIGNAL(finished()),this,SIGNAL(finished()));
connect(scxml,SIGNAL(eventTriggered(QString)),this,SIGNAL(trigger(QString)));
+ connect(scxml,SIGNAL(dataChanged(QString,QVariant)),this,SLOT(onDataChanged(QString,QVariant)));
connect(scxml,SIGNAL(configurationChanged()),this,SLOT(checkConfig()));
if (m_states)
delete m_states;
@@ -185,18 +188,42 @@ void QmlScxml::setSource(const QUrl & u)
}
}
+class QmlScxmlDataTestTimer : public QTimer
+{
+ QString key;
+ QScxml* scxml;
+ QmlPropertyMap* propMap;
+ public:
+ QmlScxmlDataTestTimer(const QString & k, QScxml* qs, QmlPropertyMap* pm)
+ : QTimer(qs),key(k),scxml(qs),propMap(pm)
+ {
+ setInterval(0);
+ setSingleShot(true);
+ start();
+ }
+
+ void timerEvent(QTimerEvent* te)
+ {
+ if (te->timerId() == timerId()) {
+
+ scxml->setData(key,propMap->value(key));
+ deleteLater();
+ }
+ }
+
+};
+
void QmlScxml::onDataChanged(const QString & key)
{
- qDebug() << "onDataChanged" << key;
- m_data->blockSignals(true);
- scxml->setData(key,(*m_data)[key]);
- m_data->blockSignals(false);
+ new QmlScxmlDataTestTimer(key,scxml,m_data);
}
void QmlScxml::onDataChanged(const QString & key, const QVariant & value)
{
- qDebug() << "onDataChanged" << key << value;
if (m_data) {
- (*m_data)[key] = value;
+ if ((*m_data)[key] != value) {
+ (*m_data)[key] = value;
+ emit dataChanged(m_data);
+ }
}
}
@@ -243,7 +270,7 @@ void QmlScxml::setRunning(bool r)
void QmlScxml::raise(const QString & e)
{
if (scxml) {
- scxml->postNamedEvent(e);
+ scxml->postDelayedEvent(new QScxmlEvent(e),0);
}
}
void QmlScxml::stop()