summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp6
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp10
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp62
-rw-r--r--src/declarative/qml/qdeclarativecompiler_p.h2
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp4
-rw-r--r--src/declarative/qml/qdeclarativecontextscriptclass.cpp30
-rw-r--r--src/declarative/qml/qdeclarativecontextscriptclass_p.h1
-rw-r--r--src/declarative/qml/qdeclarativedeclarativedata_p.h5
-rw-r--r--src/declarative/qml/qdeclarativedom.cpp8
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp46
-rw-r--r--src/declarative/qml/qdeclarativeexpression_p.h5
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass.cpp15
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass_p.h7
-rw-r--r--src/declarative/qml/qdeclarativeproperty.cpp11
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp18
-rw-r--r--src/declarative/util/qdeclarativebehavior.cpp6
-rw-r--r--src/declarative/util/qdeclarativebind.cpp15
-rw-r--r--src/declarative/util/qdeclarativeeasefollow.cpp34
-rw-r--r--src/declarative/util/qdeclarativespringfollow.cpp6
20 files changed, 187 insertions, 106 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 090c46d..5b313be 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -744,7 +744,7 @@ QDeclarativeGridView::~QDeclarativeGridView()
id: myDelegate
Item {
id: wrapper
- GridView.onRemove: SequentialAnimation {
+ SequentialAnimation on GridView.onRemove {
PropertyAction { target: wrapper.GridView; property: "delayRemove"; value: true }
NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" }
PropertyAction { target: wrapper.GridView; property: "delayRemove"; value: false }
@@ -989,8 +989,8 @@ void QDeclarativeGridView::setHighlight(QDeclarativeComponent *highlight)
id: myHighlight
Rectangle {
id: wrapper; color: "lightsteelblue"; radius: 4; width: 320; height: 60
- y: SpringFollow { source: Wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 }
- x: SpringFollow { source: Wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 }
+ SpringFollow on y { source: Wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 }
+ SpringFollow on x { source: Wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 }
}
}
\endcode
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index a05e638..eb5315d 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -1431,7 +1431,7 @@ QDeclarativeListView::~QDeclarativeListView()
id: myDelegate
Item {
id: wrapper
- ListView.onRemove: SequentialAnimation {
+ SequentialAnimation on ListView.onRemove {
PropertyAction { target: wrapper.ListView; property: "delayRemove"; value: true }
NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" }
PropertyAction { target: wrapper.ListView; property: "delayRemove"; value: false }
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index a0aed46..55f1c89 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -144,7 +144,7 @@ QDeclarativeVisualItemModel::QDeclarativeVisualItemModel()
QDeclarativeListProperty<QDeclarativeItem> QDeclarativeVisualItemModel::children()
{
Q_D(QDeclarativeVisualItemModel);
- return QDeclarativeListProperty<QDeclarativeItem>(this, d, d->children_append,
+ return QDeclarativeListProperty<QDeclarativeItem>(this, d, d->children_append,
d->children_count, d->children_at);
}
@@ -483,7 +483,7 @@ QVariant QDeclarativeVisualDataModelDataMetaObject::initialValue(int propId)
QDeclarativeVisualDataModelData::QDeclarativeVisualDataModelData(int index,
QDeclarativeVisualDataModel *model)
-: m_index(index), m_model(model),
+: m_index(index), m_model(model),
m_meta(new QDeclarativeVisualDataModelDataMetaObject(this, QDeclarativeVisualDataModelPrivate::get(model)->m_delegateDataType))
{
QDeclarativeVisualDataModelPrivate *modelPriv = QDeclarativeVisualDataModelPrivate::get(model);
@@ -550,7 +550,7 @@ QVariant QDeclarativeVisualDataModelPartsMetaObject::initialValue(int id)
}
QDeclarativeVisualDataModelParts::QDeclarativeVisualDataModelParts(QDeclarativeVisualDataModel *parent)
-: QObject(parent), model(parent)
+: QObject(parent), model(parent)
{
new QDeclarativeVisualDataModelPartsMetaObject(this);
}
@@ -840,7 +840,7 @@ void QDeclarativeVisualDataModel::setDelegate(QDeclarativeComponent *delegate)
Rectangle {
height: 25; width: 100
Text { text: path }
- MouseRegion {
+ MouseArea {
anchors.fill: parent;
onClicked: myModel.setRoot(path)
}
@@ -969,7 +969,7 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q
QObject *QDeclarativeVisualDataModel::parts()
{
Q_D(QDeclarativeVisualDataModel);
- if (!d->m_parts)
+ if (!d->m_parts)
d->m_parts = new QDeclarativeVisualDataModelParts(this);
return d->m_parts;
}
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index a9809c0..1eea012 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -65,6 +65,7 @@
#include "qdeclarativescriptparser_p.h"
#include "qdeclarativebinding_p.h"
#include "qdeclarativecompiledbindings_p.h"
+#include "qdeclarativeglobalscriptclass_p.h"
#include <qfxperf_p_p.h>
@@ -113,32 +114,6 @@ QList<QDeclarativeError> QDeclarativeCompiler::errors() const
}
/*!
- Returns true if \a val is a legal object id, false otherwise.
-
- Legal ids must start with a lower-case letter or underscore, and contain only
- letters, numbers and underscores.
-*/
-bool QDeclarativeCompiler::isValidId(const QString &val)
-{
- if (val.isEmpty())
- return false;
-
- if (val.at(0).isLetter() && !val.at(0).isLower()) {
- qWarning().nospace() << "id " << val << " is invalid: ids cannot start with uppercase letters";
- return false;
- }
-
- QChar u(QLatin1Char('_'));
- for (int ii = 0; ii < val.count(); ++ii)
- if (val.at(ii) != u &&
- ((ii == 0 && !val.at(ii).isLetter()) ||
- (ii != 0 && !val.at(ii).isLetterOrNumber())) )
- return false;
-
- return true;
-}
-
-/*!
Returns true if \a name refers to an attached property, false otherwise.
Attached property names are those that start with a capital letter.
@@ -1140,10 +1115,11 @@ bool QDeclarativeCompiler::buildComponent(QDeclarativeParser::Object *obj,
if (obj->properties.count())
idProp = *obj->properties.begin();
- if (idProp && (idProp->value || idProp->values.count() > 1 || !isValidId(idProp->values.first()->primitive())))
- COMPILE_EXCEPTION(idProp, QCoreApplication::translate("QDeclarativeCompiler","Invalid component id specification"));
-
if (idProp) {
+ if (idProp->value || idProp->values.count() > 1 || idProp->values.at(0)->object)
+ COMPILE_EXCEPTION(idProp, QCoreApplication::translate("QDeclarativeCompiler","Invalid component id specification"));
+ COMPILE_CHECK(checkValidId(idProp->values.first(), idProp->values.first()->primitive()));
+
QString idVal = idProp->values.first()->primitive();
if (compileState.ids.contains(idVal))
@@ -1726,8 +1702,7 @@ bool QDeclarativeCompiler::buildIdProperty(QDeclarativeParser::Property *prop,
QDeclarativeParser::Value *idValue = prop->values.at(0);
QString val = idValue->primitive();
- if (!isValidId(val))
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","\"%1\" is not a valid object id").arg(val));
+ COMPILE_CHECK(checkValidId(idValue, val));
// We disallow id's that conflict with import prefixes and types
QDeclarativeEnginePrivate::ImportedNamespace *ns = 0;
@@ -2476,6 +2451,31 @@ bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeParser::Object *obj, Dyn
return true;
}
+bool QDeclarativeCompiler::checkValidId(QDeclarativeParser::Value *v, const QString &val)
+{
+ if (val.isEmpty())
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "Invalid empty ID"));
+
+ if (val.at(0).isLetter() && !val.at(0).isLower())
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "IDs cannot start with an uppercase letter"));
+
+ QChar u(QLatin1Char('_'));
+ for (int ii = 0; ii < val.count(); ++ii) {
+
+ if (ii == 0 && !val.at(ii).isLetter() && val.at(ii) != u) {
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "IDs must start with a letter or underscore"));
+ } else if (ii != 0 && !val.at(ii).isLetterOrNumber() && val.at(ii) != u) {
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "IDs must contain only letters, numbers, and underscores"));
+ }
+
+ }
+
+ if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(val))
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "ID illegally masks global JavaScript property"));
+
+ return true;
+}
+
#include <qdeclarativejsparser_p.h>
static QStringList astNodeToStringList(QDeclarativeJS::AST::Node *node)
diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h
index 93a3f83..f8ada95 100644
--- a/src/declarative/qml/qdeclarativecompiler_p.h
+++ b/src/declarative/qml/qdeclarativecompiler_p.h
@@ -155,7 +155,6 @@ public:
bool isError() const;
QList<QDeclarativeError> errors() const;
- static bool isValidId(const QString &);
static bool isAttachedPropertyName(const QByteArray &);
static bool isSignalPropertyName(const QByteArray &);
@@ -247,6 +246,7 @@ private:
QDeclarativeParser::Object *obj,
const QDeclarativeParser::Object::DynamicProperty &);
bool completeComponentBuild();
+ bool checkValidId(QDeclarativeParser::Value *, const QString &);
void genObject(QDeclarativeParser::Object *obj);
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index b244cd8..35e7a77 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -47,6 +47,7 @@
#include "qdeclarativeengine.h"
#include "qdeclarativecompiledbindings_p.h"
#include "qdeclarativeinfo.h"
+#include "qdeclarativeglobalscriptclass_p.h"
#include <qscriptengine.h>
#include <QtCore/qvarlengtharray.h>
@@ -74,10 +75,13 @@ void QDeclarativeContextPrivate::addScript(const QDeclarativeParser::Object::Scr
QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
+
scriptContext->pushScope(enginePriv->contextClass->newContext(q, scopeObject));
+ scriptContext->pushScope(enginePriv->globalClass->globalObject());
QScriptValue scope = scriptEngine->newObject();
scriptContext->setActivationObject(scope);
+ scriptContext->pushScope(scope);
for (int ii = 0; ii < script.codes.count(); ++ii) {
scriptEngine->evaluate(script.codes.at(ii), script.files.at(ii), script.lineNumbers.at(ii));
diff --git a/src/declarative/qml/qdeclarativecontextscriptclass.cpp b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
index 7deed0b..d6305d8 100644
--- a/src/declarative/qml/qdeclarativecontextscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
@@ -50,10 +50,11 @@
QT_BEGIN_NAMESPACE
struct ContextData : public QScriptDeclarativeClass::Object {
- ContextData() : isSharedContext(true) {}
- ContextData(QDeclarativeContext *c, QObject *o) : context(c), scopeObject(o), isSharedContext(false) {}
+ ContextData() : overrideObject(0), isSharedContext(true) {}
+ ContextData(QDeclarativeContext *c, QObject *o) : context(c), scopeObject(o), overrideObject(0), isSharedContext(false) {}
QDeclarativeGuard<QDeclarativeContext> context;
QDeclarativeGuard<QObject> scopeObject;
+ QObject *overrideObject;
bool isSharedContext;
QDeclarativeContext *getContext(QDeclarativeEngine *engine) {
@@ -110,6 +111,17 @@ QDeclarativeContext *QDeclarativeContextScriptClass::contextFromValue(const QScr
return data->getContext(engine);
}
+QObject *QDeclarativeContextScriptClass::setOverrideObject(QScriptValue &v, QObject *override)
+{
+ if (scriptClass(v) != this)
+ return 0;
+
+ ContextData *data = (ContextData *)object(v);
+ QObject *rv = data->overrideObject;
+ data->overrideObject = override;
+ return rv;
+}
+
QScriptClass::QueryFlags
QDeclarativeContextScriptClass::queryProperty(Object *object, const Identifier &name,
QScriptClass::QueryFlags flags)
@@ -127,6 +139,20 @@ QDeclarativeContextScriptClass::queryProperty(Object *object, const Identifier &
if (!bindContext)
return 0;
+ QObject *overrideObject = ((ContextData *)object)->overrideObject;
+ if (overrideObject) {
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ QScriptClass::QueryFlags rv =
+ ep->objectClass->queryProperty(overrideObject, name, flags, bindContext,
+ QDeclarativeObjectScriptClass::ImplicitObject |
+ QDeclarativeObjectScriptClass::SkipAttachedProperties);
+ if (rv) {
+ lastScopeObject = overrideObject;
+ lastContext = bindContext;
+ return rv;
+ }
+ }
+
bool includeTypes = true;
while (bindContext) {
QScriptClass::QueryFlags rv =
diff --git a/src/declarative/qml/qdeclarativecontextscriptclass_p.h b/src/declarative/qml/qdeclarativecontextscriptclass_p.h
index 26086ec..4b0dca0 100644
--- a/src/declarative/qml/qdeclarativecontextscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativecontextscriptclass_p.h
@@ -70,6 +70,7 @@ public:
QScriptValue newSharedContext();
QDeclarativeContext *contextFromValue(const QScriptValue &);
+ QObject *setOverrideObject(QScriptValue &, QObject *);
protected:
virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
diff --git a/src/declarative/qml/qdeclarativedeclarativedata_p.h b/src/declarative/qml/qdeclarativedeclarativedata_p.h
index a7a73bc..ae40130 100644
--- a/src/declarative/qml/qdeclarativedeclarativedata_p.h
+++ b/src/declarative/qml/qdeclarativedeclarativedata_p.h
@@ -120,6 +120,11 @@ public:
template<class T>
void QDeclarativeGuard<T>::addGuard()
{
+ if (QObjectPrivate::get(o)->wasDeleted) {
+ if (prev) remGuard();
+ return;
+ }
+
QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(o, true);
next = data->guards;
if (next) reinterpret_cast<QDeclarativeGuard<T> *>(next)->prev = &next;
diff --git a/src/declarative/qml/qdeclarativedom.cpp b/src/declarative/qml/qdeclarativedom.cpp
index 5b43109..cb56ead 100644
--- a/src/declarative/qml/qdeclarativedom.cpp
+++ b/src/declarative/qml/qdeclarativedom.cpp
@@ -374,7 +374,7 @@ QDeclarativeDomValue QDeclarativeDomProperty::value() const
QDeclarativeDomValue rv;
if (d->property) {
rv.d->property = d->property;
- if (d->property->values.count())
+ if (d->property->values.count())
rv.d->value = d->property->values.at(0);
else
rv.d->value = d->property->onValues.at(0);
@@ -508,7 +508,7 @@ int QDeclarativeDomDynamicProperty::propertyType() const
QByteArray QDeclarativeDomDynamicProperty::propertyTypeName() const
{
- if (isValid())
+ if (isValid())
return d->property.customType;
return QByteArray();
@@ -1184,7 +1184,7 @@ QDeclarativeDomObject QDeclarativeDomValueValueSource::object() const
\qml
Rectangle {
- x: Behavior { NumberAnimation { duration: 500 } }
+ Behavior on x { NumberAnimation { duration: 500 } }
}
\endqml
*/
@@ -1228,7 +1228,7 @@ QDeclarativeDomValueValueInterceptor &QDeclarativeDomValueValueInterceptor::oper
returned.
\qml
Rectangle {
- x: Behavior { NumberAnimation { duration: 500 } }
+ Behavior on x { NumberAnimation { duration: 500 } }
}
\endqml
*/
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
index ae1e790..e528e9e 100644
--- a/src/declarative/qml/qdeclarativeexpression.cpp
+++ b/src/declarative/qml/qdeclarativeexpression.cpp
@@ -46,6 +46,7 @@
#include "qdeclarativecontext_p.h"
#include "qdeclarativerewrite_p.h"
#include "qdeclarativecompiler_p.h"
+#include "qdeclarativeglobalscriptclass_p.h"
#include <QtCore/qdebug.h>
#include <QtScript/qscriptprogram.h>
@@ -135,6 +136,7 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, void *expr,
if (!dd->cachedClosures.at(progIdx)) {
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
scriptContext->pushScope(ep->contextClass->newSharedContext());
+ scriptContext->pushScope(ep->globalClass->globalObject());
dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(data->expression, data->url, data->line));
scriptEngine->popContext();
}
@@ -151,9 +153,11 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, void *expr,
new QScriptProgram(data->expression, data->url, data->line);
}
- data->expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx));
+ data->expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx),
+ &data->expressionContext);
#else
- data->expressionFunction = evalInObjectScope(ctxt, me, data->expression);
+ data->expressionFunction = evalInObjectScope(ctxt, me, data->expression,
+ &data->expressionContext);
#endif
data->expressionFunctionValid = true;
@@ -164,22 +168,34 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, void *expr,
}
QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContext *context, QObject *object,
- const QString &program)
+ const QString &program, QScriptValue *contextObject)
{
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine());
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(&ep->scriptEngine);
- scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ if (contextObject) {
+ *contextObject = ep->contextClass->newContext(context, object);
+ scriptContext->pushScope(*contextObject);
+ } else {
+ scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ }
+ scriptContext->pushScope(ep->globalClass->globalObject());
QScriptValue rv = ep->scriptEngine.evaluate(program);
ep->scriptEngine.popContext();
return rv;
}
QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContext *context, QObject *object,
- const QScriptProgram &program)
+ const QScriptProgram &program, QScriptValue *contextObject)
{
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine());
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(&ep->scriptEngine);
- scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ if (contextObject) {
+ *contextObject = ep->contextClass->newContext(context, object);
+ scriptContext->pushScope(*contextObject);
+ } else {
+ scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ }
+ scriptContext->pushScope(ep->globalClass->globalObject());
QScriptValue rv = ep->scriptEngine.evaluate(program);
ep->scriptEngine.popContext();
return rv;
@@ -326,15 +342,14 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo
QDeclarativeEngine *engine = data->context()->engine();
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
- if (secondaryScope)
- ctxtPriv->defaultObjects.append(secondaryScope);
-
QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
if (!data->expressionFunctionValid) {
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
- scriptContext->pushScope(ep->contextClass->newContext(data->context(), data->me));
+ data->expressionContext = ep->contextClass->newContext(data->context(), data->me);
+ scriptContext->pushScope(data->expressionContext);
+ scriptContext->pushScope(ep->globalClass->globalObject());
if (data->expressionRewritten) {
data->expressionFunction = scriptEngine->evaluate(data->expression,
@@ -357,11 +372,14 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo
QDeclarativeContext *oldSharedContext = 0;
QObject *oldSharedScope = 0;
+ QObject *oldOverride = 0;
if (data->isShared) {
oldSharedContext = ep->sharedContext;
oldSharedScope = ep->sharedScope;
ep->sharedContext = data->context();
ep->sharedScope = data->me;
+ } else {
+ oldOverride = ep->contextClass->setOverrideObject(data->expressionContext, secondaryScope);
}
QScriptValue svalue = data->expressionFunction.call();
@@ -369,6 +387,8 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo
if (data->isShared) {
ep->sharedContext = oldSharedContext;
ep->sharedScope = oldSharedScope;
+ } else {
+ ep->contextClass->setOverrideObject(data->expressionContext, oldOverride);
}
if (isUndefined)
@@ -383,12 +403,6 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo
data->error = QDeclarativeError();
}
- if (secondaryScope) {
- QObject *last = ctxtPriv->defaultObjects.takeLast();
- Q_ASSERT(last == secondaryScope);
- Q_UNUSED(last);
- }
-
QVariant rv;
if (svalue.isArray()) {
diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h
index 91ac4c0..cd1729d 100644
--- a/src/declarative/qml/qdeclarativeexpression_p.h
+++ b/src/declarative/qml/qdeclarativeexpression_p.h
@@ -119,6 +119,7 @@ public:
bool expressionFunctionValid:1;
bool expressionRewritten:1;
QScriptValue expressionFunction;
+ QScriptValue expressionContext;
QObject *me;
bool trackChange;
@@ -180,8 +181,8 @@ public:
virtual void emitValueChanged();
static void exceptionToError(QScriptEngine *, QDeclarativeError &);
- static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QString &);
- static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QScriptProgram &);
+ static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QString &, QScriptValue * = 0);
+ static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QScriptProgram &, QScriptValue * = 0);
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
index 5b06b42..9ee2fe5 100644
--- a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
@@ -53,15 +53,17 @@ QT_BEGIN_NAMESPACE
QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(QScriptEngine *engine)
: QScriptClass(engine)
{
- QScriptValue v = engine->newObject();
- globalObject = engine->globalObject();
+ QScriptValue globalObject = engine->globalObject();
+ m_globalObject = engine->newObject();
QScriptValueIterator iter(globalObject);
while (iter.hasNext()) {
iter.next();
- v.setProperty(iter.scriptName(), iter.value());
+ m_globalObject.setProperty(iter.scriptName(), iter.value());
+ m_illegalNames.insert(iter.name());
}
+ QScriptValue v = engine->newObject();
v.setScriptClass(this);
engine->setGlobalObject(v);
}
@@ -101,12 +103,14 @@ void QDeclarativeGlobalScriptClass::setProperty(QScriptValue &object,
engine()->currentContext()->throwError(error);
}
+/* This method is for the use of tst_qdeclarativeecmascript::callQtInvokables() only */
void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, const QScriptValue &value)
{
+ QScriptValue globalObject = engine()->globalObject();
+
QScriptValue v = engine()->newObject();
- globalObject = engine()->globalObject();
- QScriptValueIterator iter(globalObject);
+ QScriptValueIterator iter(v);
while (iter.hasNext()) {
iter.next();
v.setProperty(iter.scriptName(), iter.value());
@@ -114,6 +118,7 @@ void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, con
v.setProperty(name, value);
v.setScriptClass(this);
+
engine()->setGlobalObject(v);
}
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
index a33cf5e..1b34aee 100644
--- a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
@@ -54,6 +54,7 @@
//
#include <QtScript/qscriptclass.h>
+#include <QtCore/qset.h>
QT_BEGIN_NAMESPACE
@@ -74,8 +75,12 @@ public:
void explicitSetProperty(const QString &, const QScriptValue &);
+ const QScriptValue &globalObject() const { return m_globalObject; }
+ const QSet<QString> &illegalNames() const { return m_illegalNames; }
+
private:
- QScriptValue globalObject;
+ QSet<QString> m_illegalNames;
+ QScriptValue m_globalObject;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp
index e1ec2cd..521c241 100644
--- a/src/declarative/qml/qdeclarativeproperty.cpp
+++ b/src/declarative/qml/qdeclarativeproperty.cpp
@@ -793,7 +793,7 @@ QVariant QDeclarativeProperty::read(QObject *object, const QString &name, QDecla
QVariant QDeclarativePropertyPrivate::readValueProperty()
{
- if(isValueType()) {
+ if (isValueType()) {
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context);
QDeclarativeValueType *valueType = 0;
@@ -809,13 +809,20 @@ QVariant QDeclarativePropertyPrivate::readValueProperty()
if (!ep) delete valueType;
return rv;
- } else if(core.flags & QDeclarativePropertyCache::Data::IsQList) {
+ } else if (core.flags & QDeclarativePropertyCache::Data::IsQList) {
QDeclarativeListProperty<QObject> prop;
void *args[] = { &prop, 0 };
QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
return QVariant::fromValue(QDeclarativeListReferencePrivate::init(prop, core.propType, engine));
+ } else if (core.flags & QDeclarativePropertyCache::Data::IsQObjectDerived) {
+
+ QObject *rv = 0;
+ void *args[] = { &rv, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
+ return QVariant::fromValue(rv);
+
} else {
return object->metaObject()->property(core.coreIndex).read(object.data());
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 7f4f1c0..b14de19 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -110,7 +110,7 @@ QDeclarativeAbstractAnimation::QDeclarativeAbstractAnimation(QDeclarativeAbstrac
\code
Rectangle {
width: 100; height: 100
- x: NumberAnimation {
+ NumberAnimation on x {
running: myMouse.pressed
from: 0; to: 100
}
@@ -310,7 +310,7 @@ void QDeclarativeAbstractAnimation::setAlwaysRunToEnd(bool f)
\code
Rectangle {
- rotation: NumberAnimation { running: true; repeat: true; from: 0 to: 360 }
+ NumberAnimation on rotation { running: true; repeat: true; from: 0 to: 360 }
}
\endcode
*/
@@ -412,7 +412,7 @@ void QDeclarativeAbstractAnimation::resume()
no further influence on property values. In this example animation
\code
Rectangle {
- x: NumberAnimation { from: 0; to: 100; duration: 500 }
+ NumberAnimation on x { from: 0; to: 100; duration: 500 }
}
\endcode
was stopped at time 250ms, the \c x property will have a value of 50.
@@ -450,7 +450,7 @@ void QDeclarativeAbstractAnimation::restart()
its end. In the following example,
\code
Rectangle {
- x: NumberAnimation { from: 0; to: 100; duration: 500 }
+ NumberAnimation on x { from: 0; to: 100; duration: 500 }
}
\endcode
calling \c stop() at time 250ms will result in the \c x property having
@@ -1292,7 +1292,7 @@ QDeclarativeVector3dAnimation::QDeclarativeVector3dAnimation(QObject *parent)
Q_D(QDeclarativePropertyAnimation);
d->interpolatorType = QMetaType::QVector3D;
d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
- d->defaultToInterpolatorType = true;
+ d->defaultToInterpolatorType = true;
}
QDeclarativeVector3dAnimation::~QDeclarativeVector3dAnimation()
@@ -1741,7 +1741,7 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int
Animate all changes to a rectangle's x property.
\qml
Rectangle {
- x: Behavior { PropertyAnimation {} }
+ Behavior on x { PropertyAnimation {} }
}
\endqml
\o As a property value source
@@ -1749,7 +1749,7 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int
Repeatedly animate the rectangle's x property.
\qml
Rectangle {
- x: SequentialAnimation {
+ SequentialAnimation on x {
repeat: true
PropertyAnimation { to: 50 }
PropertyAnimation { to: 0 }
@@ -2140,8 +2140,8 @@ void QDeclarativePropertyAnimation::setProperties(const QString &prop)
id: theRect
width: 100; height: 100
color: Qt.rgba(0,0,1)
- x: NumberAnimation { to: 500; repeat: true } //animate theRect's x property
- y: Behavior { NumberAnimation {} } //animate theRect's y property
+ NumberAnimation on x { to: 500; repeat: true } //animate theRect's x property
+ Behavior on y { NumberAnimation {} } //animate theRect's y property
}
\endqml
\row
diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp
index 5352341..dea2c02 100644
--- a/src/declarative/util/qdeclarativebehavior.cpp
+++ b/src/declarative/util/qdeclarativebehavior.cpp
@@ -75,13 +75,13 @@ public:
Behaviors provide one way to specify \l{qdeclarativeanimation.html}{animations} in QML.
- In the example below, the rect will use a bounce easing curve over 200 millisecond for any changes to its y property:
+ In the example below, the rectangle will use a bounce easing curve over 200 millisecond for any changes to its y property:
\code
Rectangle {
width: 20; height: 20
color: "#00ff00"
- y: 200 //initial value
- y: Behavior {
+ y: 200 // initial value
+ Behavior on y {
NumberAnimation {
easing: "easeOutBounce(amplitude:100)"
duration: 200
diff --git a/src/declarative/util/qdeclarativebind.cpp b/src/declarative/util/qdeclarativebind.cpp
index e95a03e..26baa38 100644
--- a/src/declarative/util/qdeclarativebind.cpp
+++ b/src/declarative/util/qdeclarativebind.cpp
@@ -72,7 +72,7 @@ public:
/*!
\qmlclass Binding QDeclarativeBind
- \since 4.7
+ \since 4.7
\brief The Binding element allows arbitrary property bindings to be created.
Sometimes it is necessary to bind to a property of an object that wasn't
@@ -114,6 +114,19 @@ QDeclarativeBind::~QDeclarativeBind()
{
}
+/*!
+ \qmlproperty bool Binding::when
+
+ This property holds when the binding is active.
+ This should be set to an expression that evaluates to true when you want the binding to be active.
+
+ \code
+ Binding {
+ target: contactName; property: 'text'
+ value: name; when: list.ListView.isCurrentItem
+ }
+ \endcode
+*/
bool QDeclarativeBind::when() const
{
Q_D(const QDeclarativeBind);
diff --git a/src/declarative/util/qdeclarativeeasefollow.cpp b/src/declarative/util/qdeclarativeeasefollow.cpp
index 3fa9866..ee181dd 100644
--- a/src/declarative/util/qdeclarativeeasefollow.cpp
+++ b/src/declarative/util/qdeclarativeeasefollow.cpp
@@ -59,10 +59,10 @@ class QDeclarativeEaseFollowPrivate : public QObjectPrivate
public:
QDeclarativeEaseFollowPrivate()
: source(0), velocity(200), duration(-1), maximumEasingTime(-1),
- reversingMode(QDeclarativeEaseFollow::Eased), initialVelocity(0),
+ reversingMode(QDeclarativeEaseFollow::Eased), initialVelocity(0),
initialValue(0), invert(false), enabled(true), trackVelocity(0), clockOffset(0),
lastTick(0), clock(this)
- {}
+ {}
qreal source;
qreal velocity;
@@ -173,7 +173,7 @@ bool QDeclarativeEaseFollowPrivate::recalc()
}
/*
- qWarning() << "a:" << a << "tf:" << tf << "tp:" << tp << "vp:"
+ qWarning() << "a:" << a << "tf:" << tf << "tp:" << tp << "vp:"
<< vp << "sp:" << sp << "vi:" << vi << "invert:" << invert;
*/
return true;
@@ -254,19 +254,19 @@ void QDeclarativeEaseFollowPrivate::tick(int t)
\since 4.7
\brief The EaseFollow element allows a property to smoothly track a value.
- The EaseFollow smoothly animates a property's value to a set target value
+ The EaseFollow smoothly animates a property's value to a set target value
using an ease in/out quad easing curve. If the target value changes while
- the animation is in progress, the easing curves used to animate to the old
+ the animation is in progress, the easing curves used to animate to the old
and the new target values are spliced together to avoid any obvious visual
glitches.
The property animation is configured by setting the velocity at which the
- animation should occur, or the duration that the animation should take.
+ animation should occur, or the duration that the animation should take.
If both a velocity and a duration are specified, the one that results in
the quickest animation is chosen for each change in the target value.
For example, animating from 0 to 800 will take 4 seconds if a velocity
- of 200 is set, will take 8 seconds with a duration of 8000 set, and will
+ of 200 is set, will take 8 seconds with a duration of 8000 set, and will
take 4 seconds with both a velocity of 200 and a duration of 8000 set.
Animating from 0 to 20000 will take 10 seconds if a velocity of 200 is set,
will take 8 seconds with a duration of 8000 set, and will take 8 seconds
@@ -283,8 +283,8 @@ Rectangle {
color: "green"
width: 60; height: 60;
x: -5; y: -5;
- x: EaseFollow { source: rect1.x - 5; velocity: 200 }
- y: EaseFollow { source: rect1.y - 5; velocity: 200 }
+ EaseFollow on x { source: rect1.x - 5; velocity: 200 }
+ EaseFollow on y { source: rect1.y - 5; velocity: 200 }
}
Rectangle {
@@ -338,8 +338,8 @@ qreal QDeclarativeEaseFollow::sourceValue() const
Sets how the EaseFollow behaves if an animation direction is reversed.
If reversing mode is \c Eased, the animation will smoothly decelerate, and
- then reverse direction. If the reversing mode is \c Immediate, the
- animation will immediately begin accelerating in the reverse direction,
+ then reverse direction. If the reversing mode is \c Immediate, the
+ animation will immediately begin accelerating in the reverse direction,
begining with a velocity of 0. If the reversing mode is \c Sync, the
property is immediately set to the target value.
*/
@@ -373,7 +373,7 @@ void QDeclarativeEaseFollowPrivate::restart()
return;
}
- bool hasReversed = trackVelocity != 0. &&
+ bool hasReversed = trackVelocity != 0. &&
((trackVelocity > 0) == ((initialValue - source) > 0));
if (hasReversed) {
@@ -440,7 +440,7 @@ void QDeclarativeEaseFollow::setDuration(qreal v)
d->duration = v;
d->trackVelocity = 0;
- if (d->clock.state() == QAbstractAnimation::Running)
+ if (d->clock.state() == QAbstractAnimation::Running)
d->restart();
emit durationChanged();
@@ -470,7 +470,7 @@ void QDeclarativeEaseFollow::setVelocity(qreal v)
d->velocity = v;
d->trackVelocity = 0;
- if (d->clock.state() == QAbstractAnimation::Running)
+ if (d->clock.state() == QAbstractAnimation::Running)
d->restart();
emit velocityChanged();
@@ -511,8 +511,8 @@ void QDeclarativeEaseFollow::setTarget(const QDeclarativeProperty &t)
\qmlproperty qreal EaseFollow::maximumEasingTime
This property specifies the maximum time an "eases" during the follow should take.
-Setting this property causes the velocity to "level out" after at a time. Setting
-a negative value reverts to the normal mode of easing over the entire animation
+Setting this property causes the velocity to "level out" after at a time. Setting
+a negative value reverts to the normal mode of easing over the entire animation
duration.
The default value is -1.
@@ -528,7 +528,7 @@ void QDeclarativeEaseFollow::setMaximumEasingTime(qreal v)
Q_D(QDeclarativeEaseFollow);
d->maximumEasingTime = v;
- if (d->clock.state() == QAbstractAnimation::Running)
+ if (d->clock.state() == QAbstractAnimation::Running)
d->restart();
emit maximumEasingTimeChanged();
diff --git a/src/declarative/util/qdeclarativespringfollow.cpp b/src/declarative/util/qdeclarativespringfollow.cpp
index 6205ab9..1d69dd3 100644
--- a/src/declarative/util/qdeclarativespringfollow.cpp
+++ b/src/declarative/util/qdeclarativespringfollow.cpp
@@ -222,8 +222,8 @@ void QDeclarativeSpringFollowPrivate::stop()
id: rect1
width: 20; height: 20
color: "#00ff00"
- y: 200 //initial value
- y: SequentialAnimation {
+ y: 200 // initial value
+ SequentialAnimation on y {
running: true
repeat: true
NumberAnimation {
@@ -239,7 +239,7 @@ void QDeclarativeSpringFollowPrivate::stop()
x: rect1.width
width: 20; height: 20
color: "#ff0000"
- y: SpringFollow { source: rect1.y; velocity: 200 }
+ SpringFollow on y { source: rect1.y; velocity: 200 }
}
\endcode