summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/QmlChanges.txt31
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp6
-rw-r--r--src/declarative/qml/qdeclarativeboundsignal.cpp4
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp16
-rw-r--r--src/declarative/qml/qdeclarativeexpression.h2
-rw-r--r--src/declarative/qml/qdeclarativewatcher.cpp2
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp2
-rw-r--r--src/declarative/util/qdeclarativepropertychanges.cpp2
-rw-r--r--src/declarative/util/qdeclarativestategroup.cpp2
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp38
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp6
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp2
16 files changed, 61 insertions, 60 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 55f7b21..9c46467 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -3,6 +3,11 @@ The changes below are pre Qt 4.7.0 RC
Flickable: overShoot is replaced by boundsBehavior enumeration.
+C++ API
+-------
+QDeclarativeExpression::value() has been renamed to
+QDeclarativeExpression::evaluate()
+
=============================================================================
The changes below are pre Qt 4.7.0 beta
@@ -62,22 +67,22 @@ automatically 'followed' anymore.
If you want to follow an hypothetical rect1, you should do now:
-     Rectangle {
-         color: "green"
-         width: 60; height: 60;
-         x: rect1.x - 5; y: rect1.y - 5;
-         Behavior on x { SmoothedAnimation { velocity: 200 } }
-         Behavior on y { SmoothedAnimation { velocity: 200 } }
-     }
+ Rectangle {
+ color: "green"
+ width: 60; height: 60;
+ x: rect1.x - 5; y: rect1.y - 5;
+ Behavior on x { SmoothedAnimation { velocity: 200 } }
+ Behavior on y { SmoothedAnimation { velocity: 200 } }
+ }
instead of the old automatic source changed tracking:
-     Rectangle {
-         color: "green"
-         width: 60; height: 60;
-         EaseFollow on x { source: rect1.x - 5; velocity: 200 }
-         EaseFollow on y { source: rect1.y - 5; velocity: 200 }
-    }
+ Rectangle {
+ color: "green"
+ width: 60; height: 60;
+ EaseFollow on x { source: rect1.x - 5; velocity: 200 }
+ EaseFollow on y { source: rect1.y - 5; velocity: 200 }
+ }
This is a syntax and behavior change.
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 7fa8cc4..e2d8bc7 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -198,7 +198,7 @@ QVariant QDeclarativeVisualItemModel::evaluate(int index, const QString &express
QDeclarativeContext *ctxt = new QDeclarativeContext(ccontext);
ctxt->setContextObject(d->children.at(index));
QDeclarativeExpression e(ctxt, expression, objectContext);
- QVariant value = e.value();
+ QVariant value = e.evaluate();
delete ctxt;
return value;
}
@@ -1138,7 +1138,7 @@ QVariant QDeclarativeVisualDataModel::evaluate(int index, const QString &express
QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(nobj);
if (item) {
QDeclarativeExpression e(qmlContext(item), expression, objectContext);
- value = e.value();
+ value = e.evaluate();
}
} else {
QDeclarativeContext *ccontext = d->m_context;
@@ -1147,7 +1147,7 @@ QVariant QDeclarativeVisualDataModel::evaluate(int index, const QString &express
QDeclarativeVisualDataModelData *data = new QDeclarativeVisualDataModelData(index, this);
ctxt->setContextObject(data);
QDeclarativeExpression e(ctxt, expression, objectContext);
- value = e.value();
+ value = e.evaluate();
delete data;
delete ctxt;
}
diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp
index 00a93cc..a10e013 100644
--- a/src/declarative/qml/qdeclarativeboundsignal.cpp
+++ b/src/declarative/qml/qdeclarativeboundsignal.cpp
@@ -97,8 +97,6 @@ QDeclarativeBoundSignal::QDeclarativeBoundSignal(QObject *scope, const QMetaMeth
QObject *parent)
: m_expression(0), m_signal(signal), m_paramsValid(false), m_params(0)
{
- // A cached evaluation of the QDeclarativeExpression::value() slot index.
- //
// This is thread safe. Although it may be updated by two threads, they
// will both set it to the same value - so the worst thing that can happen
// is that they both do the work to figure it out. Boo hoo.
@@ -113,8 +111,6 @@ QDeclarativeBoundSignal::QDeclarativeBoundSignal(QDeclarativeContext *ctxt, cons
QObject *parent)
: m_expression(0), m_signal(signal), m_paramsValid(false), m_params(0)
{
- // A cached evaluation of the QDeclarativeExpression::value() slot index.
- //
// This is thread safe. Although it may be updated by two threads, they
// will both set it to the same value - so the worst thing that can happen
// is that they both do the work to figure it out. Boo hoo.
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index 264fd8d..69e42f8 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -416,7 +416,7 @@ void QDeclarativeEngineDebugServer::messageReceived(const QByteArray &message)
if (object && context) {
QDeclarativeExpression exprObj(context, expr, object);
bool undefined = false;
- QVariant value = exprObj.value(&undefined);
+ QVariant value = exprObj.evaluate(&undefined);
if (undefined)
result = QLatin1String("<undefined>");
else
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
index 8b5a62f..238beb8 100644
--- a/src/declarative/qml/qdeclarativeexpression.cpp
+++ b/src/declarative/qml/qdeclarativeexpression.cpp
@@ -479,18 +479,18 @@ QVariant QDeclarativeExpressionPrivate::value(QObject *secondaryScope, bool *isU
}
/*!
- Returns the value of the expression, or an invalid QVariant if the
- expression is invalid or has an error.
+ Evaulates the expression, returning the result of the evaluation,
+ or an invalid QVariant if the expression is invalid or has an error.
- \a isUndefined is set to true if the expression resulted in an
+ \a valueIsUndefined is set to true if the expression resulted in an
undefined value.
\sa hasError(), error()
*/
-QVariant QDeclarativeExpression::value(bool *isUndefined)
+QVariant QDeclarativeExpression::evaluate(bool *valueIsUndefined)
{
Q_D(QDeclarativeExpression);
- return d->value(0, isUndefined);
+ return d->value(0, valueIsUndefined);
}
/*!
@@ -569,7 +569,7 @@ QObject *QDeclarativeExpression::scopeObject() const
}
/*!
- Returns true if the last call to value() resulted in an error,
+ Returns true if the last call to evaluate() resulted in an error,
otherwise false.
\sa error(), clearError()
@@ -593,7 +593,7 @@ void QDeclarativeExpression::clearError()
}
/*!
- Return any error from the last call to value(). If there was no error,
+ Return any error from the last call to evaluate(). If there was no error,
this returns an invalid QDeclarativeError instance.
\sa hasError(), clearError()
@@ -711,7 +711,7 @@ void QDeclarativeExpressionPrivate::updateGuards(const QPODVector<QDeclarativeEn
Emitted each time the expression value changes from the last time it was
evaluated. The expression must have been evaluated at least once (by
- calling QDeclarativeExpression::value()) before this signal will be emitted.
+ calling QDeclarativeExpression::evaluate()) before this signal will be emitted.
*/
void QDeclarativeExpressionPrivate::emitValueChanged()
diff --git a/src/declarative/qml/qdeclarativeexpression.h b/src/declarative/qml/qdeclarativeexpression.h
index 35d6949..c283dd9 100644
--- a/src/declarative/qml/qdeclarativeexpression.h
+++ b/src/declarative/qml/qdeclarativeexpression.h
@@ -86,7 +86,7 @@ public:
void clearError();
QDeclarativeError error() const;
- QVariant value(bool *isUndefined = 0);
+ QVariant evaluate(bool *valueIsUndefined = 0);
Q_SIGNALS:
void valueChanged();
diff --git a/src/declarative/qml/qdeclarativewatcher.cpp b/src/declarative/qml/qdeclarativewatcher.cpp
index 9ea84b8..842b3c4 100644
--- a/src/declarative/qml/qdeclarativewatcher.cpp
+++ b/src/declarative/qml/qdeclarativewatcher.cpp
@@ -110,7 +110,7 @@ void QDeclarativeWatchProxy::notifyValueChanged()
{
QVariant v;
if (m_expr)
- v = m_expr->value();
+ v = m_expr->evaluate();
else
v = m_property.read(m_object);
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 4f7719b..3b0d264 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -780,7 +780,7 @@ void QDeclarativeScriptActionPrivate::execute()
QDeclarativeData *ddata = QDeclarativeData::get(q);
if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber);
- expr.value();
+ expr.evaluate();
if (expr.hasError())
qmlInfo(q) << expr.error();
}
diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp
index 8a6937d..2641dcf 100644
--- a/src/declarative/util/qdeclarativepropertychanges.cpp
+++ b/src/declarative/util/qdeclarativepropertychanges.cpp
@@ -434,7 +434,7 @@ QDeclarativePropertyChanges::ActionList QDeclarativePropertyChanges::actions()
a.specifiedProperty = QString::fromUtf8(property);
if (d->isExplicit) {
- a.toValue = d->expressions.at(ii).second->value();
+ a.toValue = d->expressions.at(ii).second->evaluate();
} else {
QDeclarativeBinding *newBinding =
new QDeclarativeBinding(d->expressions.at(ii).second->expression(), object(), qmlContext(this));
diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp
index 81f4230..2349ce1 100644
--- a/src/declarative/util/qdeclarativestategroup.cpp
+++ b/src/declarative/util/qdeclarativestategroup.cpp
@@ -288,7 +288,7 @@ bool QDeclarativeStateGroupPrivate::updateAutoState()
QDeclarativeState *state = states.at(ii);
if (state->isWhenKnown()) {
if (!state->name().isEmpty()) {
- if (state->when() && state->when()->value().toBool()) {
+ if (state->when() && state->when()->evaluate().toBool()) {
if (stateChangeDebug())
qWarning() << "Setting auto state due to:"
<< state->when()->expression();
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index 0aad498..9049b83 100644
--- a/src/declarative/util/qdeclarativestateoperations.cpp
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -579,7 +579,7 @@ void QDeclarativeStateChangeScript::execute(Reason)
QDeclarativeData *ddata = QDeclarativeData::get(this);
if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber);
- expr.value();
+ expr.evaluate();
if (expr.hasError())
qmlInfo(this, expr.error());
}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 6939290..97fced4 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -381,7 +381,7 @@ void tst_qdeclarativeecmascript::basicExpressions()
nestedContext.setContextProperty("millipedeLegs", QVariant(100));
MyExpression expr(nest?&nestedContext:&context, expression);
- QCOMPARE(expr.value(), result);
+ QCOMPARE(expr.evaluate(), result);
}
void tst_qdeclarativeecmascript::arrayExpressions()
@@ -396,7 +396,7 @@ void tst_qdeclarativeecmascript::arrayExpressions()
context.setContextProperty("c", &obj3);
MyExpression expr(&context, "[a, b, c, 10]");
- QVariant result = expr.value();
+ QVariant result = expr.evaluate();
QCOMPARE(result.userType(), qMetaTypeId<QList<QObject *> >());
QList<QObject *> list = qvariant_cast<QList<QObject *> >(result);
QCOMPARE(list.count(), 4);
@@ -424,47 +424,47 @@ void tst_qdeclarativeecmascript::contextPropertiesTriggerReeval()
{
MyExpression expr(&context, "testProp + 1");
QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant(2));
+ QCOMPARE(expr.evaluate(), QVariant(2));
context.setContextProperty("testProp", QVariant(2));
QCOMPARE(expr.changed, true);
- QCOMPARE(expr.value(), QVariant(3));
+ QCOMPARE(expr.evaluate(), QVariant(3));
}
{
MyExpression expr(&context, "testProp + testProp + testProp");
QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant(6));
+ QCOMPARE(expr.evaluate(), QVariant(6));
context.setContextProperty("testProp", QVariant(4));
QCOMPARE(expr.changed, true);
- QCOMPARE(expr.value(), QVariant(12));
+ QCOMPARE(expr.evaluate(), QVariant(12));
}
{
MyExpression expr(&context, "testObj.stringProperty");
QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant("Hello"));
+ QCOMPARE(expr.evaluate(), QVariant("Hello"));
context.setContextProperty("testObj", &object2);
QCOMPARE(expr.changed, true);
- QCOMPARE(expr.value(), QVariant("World"));
+ QCOMPARE(expr.evaluate(), QVariant("World"));
}
{
MyExpression expr(&context, "testObj.stringProperty /**/");
QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant("World"));
+ QCOMPARE(expr.evaluate(), QVariant("World"));
context.setContextProperty("testObj", &object1);
QCOMPARE(expr.changed, true);
- QCOMPARE(expr.value(), QVariant("Hello"));
+ QCOMPARE(expr.evaluate(), QVariant("Hello"));
}
{
MyExpression expr(&context, "testObj2");
QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant::fromValue((QObject *)object3));
+ QCOMPARE(expr.evaluate(), QVariant::fromValue((QObject *)object3));
}
}
@@ -484,42 +484,42 @@ void tst_qdeclarativeecmascript::objectPropertiesTriggerReeval()
{
MyExpression expr(&context, "testObj.stringProperty");
QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant("Hello"));
+ QCOMPARE(expr.evaluate(), QVariant("Hello"));
object1.setStringProperty(QLatin1String("World"));
QCOMPARE(expr.changed, true);
- QCOMPARE(expr.value(), QVariant("World"));
+ QCOMPARE(expr.evaluate(), QVariant("World"));
}
{
MyExpression expr(&context, "testObj.objectProperty.stringProperty");
QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant());
+ QCOMPARE(expr.evaluate(), QVariant());
object1.setObjectProperty(&object2);
QCOMPARE(expr.changed, true);
expr.changed = false;
- QCOMPARE(expr.value(), QVariant("Dog"));
+ QCOMPARE(expr.evaluate(), QVariant("Dog"));
object1.setObjectProperty(&object3);
QCOMPARE(expr.changed, true);
expr.changed = false;
- QCOMPARE(expr.value(), QVariant("Cat"));
+ QCOMPARE(expr.evaluate(), QVariant("Cat"));
object1.setObjectProperty(0);
QCOMPARE(expr.changed, true);
expr.changed = false;
- QCOMPARE(expr.value(), QVariant());
+ QCOMPARE(expr.evaluate(), QVariant());
object1.setObjectProperty(&object3);
QCOMPARE(expr.changed, true);
expr.changed = false;
- QCOMPARE(expr.value(), QVariant("Cat"));
+ QCOMPARE(expr.evaluate(), QVariant("Cat"));
object3.setStringProperty("Donkey");
QCOMPARE(expr.changed, true);
expr.changed = false;
- QCOMPARE(expr.value(), QVariant("Donkey"));
+ QCOMPARE(expr.evaluate(), QVariant("Donkey"));
}
}
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
index 73aefaf..e0143a6 100644
--- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -401,7 +401,7 @@ T *tst_qdeclarativeimage::findItem(QGraphicsObject *parent, const QString &objec
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
if (index != -1) {
QDeclarativeExpression e(qmlContext(item), "index", item);
- if (e.value().toInt() == index)
+ if (e.evaluate().toInt() == index)
return static_cast<T*>(item);
} else {
return static_cast<T*>(item);
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
index e4c296f..ec97461 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
@@ -279,7 +279,7 @@ void tst_qdeclarativelistmodel::dynamic()
if (!warning.isEmpty())
QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
- int actual = e.value().toInt();
+ int actual = e.evaluate().toInt();
if (e.hasError())
qDebug() << e.error(); // errors not expected
QVERIFY(!e.hasError());
@@ -338,9 +338,9 @@ void tst_qdeclarativelistmodel::dynamic_worker()
QDeclarativeExpression e(eng.rootContext(), operations.last().toString(), &model);
if (QByteArray(QTest::currentDataTag()).startsWith("nested"))
- QVERIFY(e.value().toInt() != result);
+ QVERIFY(e.evaluate().toInt() != result);
else
- QCOMPARE(e.value().toInt(), result);
+ QCOMPARE(e.evaluate().toInt(), result);
}
delete item;
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index 6b7a361..cab4d52 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -1551,7 +1551,7 @@ T *tst_QDeclarativeListView::findItem(QGraphicsObject *parent, const QString &ob
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
if (index != -1) {
QDeclarativeExpression e(qmlContext(item), "index", item);
- if (e.value().toInt() == index)
+ if (e.evaluate().toInt() == index)
return static_cast<T*>(item);
} else {
return static_cast<T*>(item);
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index df7c511..0e3a74d 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -697,7 +697,7 @@ T *tst_QDeclarativePathView::findItem(QGraphicsObject *parent, const QString &ob
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
if (index != -1) {
QDeclarativeExpression e(qmlContext(item), "index", item);
- if (e.value().toInt() == index)
+ if (e.evaluate().toInt() == index)
return static_cast<T*>(item);
} else {
return static_cast<T*>(item);