summaryrefslogtreecommitdiffstats
path: root/src/declarative/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/util')
-rw-r--r--src/declarative/util/qmlconnection.cpp23
-rw-r--r--src/declarative/util/qmlconnection.h7
2 files changed, 17 insertions, 13 deletions
diff --git a/src/declarative/util/qmlconnection.cpp b/src/declarative/util/qmlconnection.cpp
index 2a7cf6c..5475fb2 100644
--- a/src/declarative/util/qmlconnection.cpp
+++ b/src/declarative/util/qmlconnection.cpp
@@ -51,11 +51,12 @@ QT_BEGIN_NAMESPACE
class QmlConnectionPrivate : public QObjectPrivate
{
public:
- QmlConnectionPrivate() : boundsignal(0), signalSender(0), componentcomplete(false) {}
+ QmlConnectionPrivate() : boundsignal(0), signalSender(0), scriptset(false), componentcomplete(false) {}
QmlBoundSignal *boundsignal;
QObject *signalSender;
- QString script;
+ QmlScriptString script;
+ bool scriptset;
QString signal;
bool componentcomplete;
};
@@ -154,7 +155,7 @@ void QmlConnection::connectIfValid()
if (!d->componentcomplete)
return;
// boundsignal must not exist
- if ((d->signalSender || parent()) && !d->signal.isEmpty() && !d->script.isEmpty()) {
+ if ((d->signalSender || parent()) && !d->signal.isEmpty() && d->scriptset) {
// create
// XXX scope?
int sigIdx = -1;
@@ -187,7 +188,7 @@ void QmlConnection::connectIfValid()
return;
}
- d->boundsignal = new QmlBoundSignal(qmlContext(this), d->script, sender, mo->method(sigIdx), this);
+ d->boundsignal = new QmlBoundSignal(qmlContext(this), d->script.script(), sender, mo->method(sigIdx), this);
}
}
@@ -196,7 +197,7 @@ void QmlConnection::disconnectIfValid()
Q_D(QmlConnection);
if (!d->componentcomplete)
return;
- if ((d->signalSender || parent()) && !d->signal.isEmpty() && !d->script.isEmpty()) {
+ if ((d->signalSender || parent()) && !d->signal.isEmpty() && d->scriptset) {
// boundsignal must exist
// destroy
delete d->boundsignal;
@@ -213,31 +214,33 @@ void QmlConnection::componentComplete()
/*!
- \qmlproperty string Connection::script
+ \qmlproperty script Connection::script
This property holds the JavaScript executed whenever the signal is sent.
This is the default attribute of Connection.
*/
-QString QmlConnection::script() const
+QmlScriptString QmlConnection::script() const
{
Q_D(const QmlConnection);
return d->script;
}
-void QmlConnection::setScript(const QString& script)
+void QmlConnection::setScript(const QmlScriptString& script)
{
Q_D(QmlConnection);
if ((d->signalSender || parent()) && !d->signal.isEmpty()) {
- if (d->script.isEmpty()) {
+ if (!d->scriptset) {
// mustn't exist - create
+ d->scriptset = true;
d->script = script;
connectIfValid();
} else {
// must exist - update
d->script = script;
- d->boundsignal->expression()->setExpression(script);
+ d->boundsignal->expression()->setExpression(script.script());
}
} else {
+ d->scriptset = true;
d->script = script;
}
}
diff --git a/src/declarative/util/qmlconnection.h b/src/declarative/util/qmlconnection.h
index dcaac34..3d69c6f 100644
--- a/src/declarative/util/qmlconnection.h
+++ b/src/declarative/util/qmlconnection.h
@@ -45,6 +45,7 @@
#include <QtCore/qobject.h>
#include <QtCore/qstring.h>
#include <QtDeclarative/qml.h>
+#include <QtDeclarative/qmlscriptstring.h>
QT_BEGIN_HEADER
@@ -62,7 +63,7 @@ class Q_DECLARATIVE_EXPORT QmlConnection : public QObject, public QmlParserStatu
Q_INTERFACES(QmlParserStatus)
Q_PROPERTY(QObject *sender READ signalSender WRITE setSignalSender)
- Q_PROPERTY(QString script READ script WRITE setScript)
+ Q_PROPERTY(QmlScriptString script READ script WRITE setScript)
Q_PROPERTY(QString signal READ signal WRITE setSignal)
public:
@@ -71,8 +72,8 @@ public:
QObject *signalSender() const;
void setSignalSender(QObject *);
- QString script() const;
- void setScript(const QString&);
+ QmlScriptString script() const;
+ void setScript(const QmlScriptString&);
QString signal() const;
void setSignal(const QString&);