summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlexpression.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-09-22 08:50:50 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-09-22 08:50:50 (GMT)
commit8d5a395e176239b7e3ee8822cb251b2e631c21de (patch)
tree60dee6cd158820944b892183c0d77a1af47fab97 /src/declarative/qml/qmlexpression.cpp
parent65e7073bb151bd9281b2d0be53f0c13cce90f3c0 (diff)
downloadQt-8d5a395e176239b7e3ee8822cb251b2e631c21de.zip
Qt-8d5a395e176239b7e3ee8822cb251b2e631c21de.tar.gz
Qt-8d5a395e176239b7e3ee8822cb251b2e631c21de.tar.bz2
Slight simplification of parameterized signals
Diffstat (limited to 'src/declarative/qml/qmlexpression.cpp')
-rw-r--r--src/declarative/qml/qmlexpression.cpp45
1 files changed, 28 insertions, 17 deletions
diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp
index 845dcf6..db9d39f 100644
--- a/src/declarative/qml/qmlexpression.cpp
+++ b/src/declarative/qml/qmlexpression.cpp
@@ -212,7 +212,7 @@ QVariant QmlExpressionPrivate::evalSSE()
return rv;
}
-QVariant QmlExpressionPrivate::evalQtScript()
+QVariant QmlExpressionPrivate::evalQtScript(QObject *secondaryScope)
{
#ifdef Q_ENABLE_PERFORMANCE_LOG
QFxPerfTimer<QFxPerf::BindValueQt> perfqt;
@@ -223,6 +223,9 @@ QVariant QmlExpressionPrivate::evalQtScript()
if (me)
ctxtPriv->defaultObjects.insert(ctxtPriv->highPriorityCount, me);
+ if (secondaryScope)
+ ctxtPriv->defaultObjects.insert(ctxtPriv->highPriorityCount,
+ secondaryScope);
QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
@@ -263,6 +266,8 @@ QVariant QmlExpressionPrivate::evalQtScript()
if (me)
ctxtPriv->defaultObjects.removeAt(ctxtPriv->highPriorityCount);
+ if (secondaryScope)
+ ctxtPriv->defaultObjects.removeAt(ctxtPriv->highPriorityCount);
QVariant rv;
@@ -306,42 +311,38 @@ QVariant QmlExpressionPrivate::evalQtScript()
return rv;
}
-/*!
- Returns the value of the expression, or an invalid QVariant if the
- expression is invalid or has an error.
-*/
-QVariant QmlExpression::value()
+QVariant QmlExpressionPrivate::value(QObject *secondaryScope)
{
- Q_D(QmlExpression);
+ Q_Q(QmlExpression);
QVariant rv;
- if (!engine() || (!d->sse.isValid() && d->expression.isEmpty()))
+ if (!q->engine() || (!sse.isValid() && expression.isEmpty()))
return rv;
#ifdef Q_ENABLE_PERFORMANCE_LOG
QFxPerfTimer<QFxPerf::BindValue> perf;
#endif
- QmlEnginePrivate *ep = QmlEnginePrivate::get(engine());
+ QmlEnginePrivate *ep = QmlEnginePrivate::get(q->engine());
QmlExpression *lastCurrentExpression = ep->currentExpression;
QPODVector<QmlEnginePrivate::CapturedProperty> lastCapturedProperties;
ep->capturedProperties.copyAndClear(lastCapturedProperties);
- ep->currentExpression = this;
+ ep->currentExpression = q;
- if (d->sse.isValid()) {
- rv = d->evalSSE();
+ if (sse.isValid()) {
+ rv = evalSSE();
} else {
- rv = d->evalQtScript();
+ rv = evalQtScript(secondaryScope);
}
ep->currentExpression = lastCurrentExpression;
- if ((!trackChange() || !ep->capturedProperties.count()) && d->guardList) {
- d->clearGuards();
- } else if(trackChange()) {
- d->updateGuards(ep->capturedProperties);
+ if ((!q->trackChange() || !ep->capturedProperties.count()) && guardList) {
+ clearGuards();
+ } else if(q->trackChange()) {
+ updateGuards(ep->capturedProperties);
}
lastCapturedProperties.copyAndClear(ep->capturedProperties);
@@ -350,6 +351,16 @@ QVariant QmlExpression::value()
}
/*!
+ Returns the value of the expression, or an invalid QVariant if the
+ expression is invalid or has an error.
+*/
+QVariant QmlExpression::value()
+{
+ Q_D(QmlExpression);
+ return d->value();
+}
+
+/*!
Returns true if the expression results in a constant value.
QmlExpression::value() must have been invoked at least once before the
return from this method is valid.