summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-06-30 17:22:24 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-06-30 17:22:24 (GMT)
commita6f4b0bbcf7f75bb5e615da1911c26bea2c95be3 (patch)
treee14f1bac9f4a1737c034b0922ff21550d36dc8ad /src/declarative/qml
parent95ecd7dcbf9ca26d35011b54cce04d56d4d1b843 (diff)
parented82b3d0f93b9876201aa8145eafbaf4b50f2f36 (diff)
downloadQt-a6f4b0bbcf7f75bb5e615da1911c26bea2c95be3.zip
Qt-a6f4b0bbcf7f75bb5e615da1911c26bea2c95be3.tar.gz
Qt-a6f4b0bbcf7f75bb5e615da1911c26bea2c95be3.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (61 commits) Added SET_BINDING message to QDeclarative debugger protocol Add ListView.nextSection attached property Remove the old font.outline documentation Docs - add more links to relevant examples Rewrite runtime & qmlviewer docs and emphasise that qmlviewer shouldn't Indicate default sizing option in qmlviewer Plug QdeclarativePixmapCache canceled request leak. update qml.qch to version 4.7 Undefined is undefined, and now qml warns about it Fix so window will resize with the root object (broken by Avoid duplicate code for testing initial sizes Remove an unnecessary connect() in TextInput Ensure micro focus is updated in TextEdit and TextInput Fix flow layout not taking into account whether it's width and height are implicit or not. Avoid binding loop. Ensure Loader item change listener is removed when Loader is destroyed Adapt all qmlviewer testcases to the code changes in the actual viewer. Stop QMLLauncher from crashing on exit on Mac when quitting app via the VisualDataModel hasModelChildren role shadowed user roles. Allow positioning of ListView items width sub-pixel precision. ...
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp33
-rw-r--r--src/declarative/qml/qdeclarativecompiler_p.h1
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp4
-rw-r--r--src/declarative/qml/qdeclarativecustomparser.cpp10
-rw-r--r--src/declarative/qml/qdeclarativecustomparser_p.h14
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp24
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp67
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass.cpp28
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass_p.h5
-rw-r--r--src/declarative/qml/qdeclarativeimageprovider.cpp2
-rw-r--r--src/declarative/qml/qdeclarativelist.cpp2
-rw-r--r--src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass.cpp24
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass_p.h2
-rw-r--r--src/declarative/qml/qdeclarativetypenamescriptclass.cpp4
17 files changed, 188 insertions, 36 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 80a1093..623e3df 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -815,6 +815,10 @@ bool QDeclarativeCompiler::buildObject(Object *obj, const BindingContext &ctxt)
}
}
+ QDeclarativeCustomParser *cp = 0;
+ if (isCustomParser)
+ cp = output->types.at(obj->type).type->customParser();
+
// Build all explicit properties specified
foreach(Property *prop, obj->properties) {
@@ -825,7 +829,9 @@ bool QDeclarativeCompiler::buildObject(Object *obj, const BindingContext &ctxt)
bool canDefer = false;
if (isCustomParser) {
- if (doesPropertyExist(prop, obj)) {
+ if (doesPropertyExist(prop, obj) &&
+ (!(cp->flags() & QDeclarativeCustomParser::AcceptsAttachedProperties) ||
+ !isAttachedPropertyName(prop->name))) {
int ids = compileState.ids.count();
COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
canDefer = ids == compileState.ids.count();
@@ -876,8 +882,7 @@ bool QDeclarativeCompiler::buildObject(Object *obj, const BindingContext &ctxt)
defaultProperty->release();
// Compile custom parser parts
- if (isCustomParser/* && !customProps.isEmpty()*/) {
- QDeclarativeCustomParser *cp = output->types.at(obj->type).type->customParser();
+ if (isCustomParser && !customProps.isEmpty()) {
cp->clearErrors();
cp->compiler = this;
cp->object = obj;
@@ -1356,7 +1361,7 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl
Returns true if (value) property \a prop exists on obj, false otherwise.
*/
bool QDeclarativeCompiler::doesPropertyExist(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj)
+ QDeclarativeParser::Object *obj)
{
if(isAttachedPropertyName(prop->name) || prop->name == "id")
return true;
@@ -2176,6 +2181,18 @@ int QDeclarativeCompiler::evaluateEnum(const QByteArray& script) const
return -1;
}
+const QMetaObject *QDeclarativeCompiler::resolveType(const QByteArray& name) const
+{
+ QDeclarativeType *qmltype = 0;
+ if (!enginePrivate->importDatabase.resolveType(unit->imports, name, &qmltype,
+ 0, 0, 0, 0))
+ return 0;
+ if (!qmltype)
+ return 0;
+ return qmltype->metaObject();
+}
+
+
// Ensures that the dynamic meta specification on obj is valid
bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj)
{
@@ -2199,6 +2216,10 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj)
if (QString::fromUtf8(prop.name).at(0).isUpper())
COMPILE_EXCEPTION(&prop, tr("Property names cannot begin with an upper case letter"));
+
+ if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(prop.name))
+ COMPILE_EXCEPTION(&prop, tr("Illegal property name"));
+
propNames.insert(prop.name);
}
@@ -2208,6 +2229,8 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj)
COMPILE_EXCEPTION(obj, tr("Duplicate signal name"));
if (QString::fromUtf8(name).at(0).isUpper())
COMPILE_EXCEPTION(obj, tr("Signal names cannot begin with an upper case letter"));
+ if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(name))
+ COMPILE_EXCEPTION(obj, tr("Illegal signal name"));
methodNames.insert(name);
}
for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) {
@@ -2216,6 +2239,8 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj)
COMPILE_EXCEPTION(obj, tr("Duplicate method name"));
if (QString::fromUtf8(name).at(0).isUpper())
COMPILE_EXCEPTION(obj, tr("Method names cannot begin with an upper case letter"));
+ if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(name))
+ COMPILE_EXCEPTION(obj, tr("Illegal method name"));
methodNames.insert(name);
}
diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h
index 908c703..caad376 100644
--- a/src/declarative/qml/qdeclarativecompiler_p.h
+++ b/src/declarative/qml/qdeclarativecompiler_p.h
@@ -161,6 +161,7 @@ public:
static bool isSignalPropertyName(const QByteArray &);
int evaluateEnum(const QByteArray& script) const; // for QDeclarativeCustomParser::evaluateEnum
+ const QMetaObject *resolveType(const QByteArray& name) const; // for QDeclarativeCustomParser::resolveType
private:
static void reset(QDeclarativeCompiledData *);
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index b4919ff..9d3032c 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -572,7 +572,9 @@ QScriptValue QDeclarativeComponent::createObject(QObject* parent)
{
Q_D(QDeclarativeComponent);
QDeclarativeContext* ctxt = creationContext();
- if(!ctxt)
+ if(!ctxt && d->engine)
+ ctxt = d->engine->rootContext();
+ if (!ctxt)
return QScriptValue(QScriptValue::NullValue);
QObject* ret = create(ctxt);
if (!ret)
diff --git a/src/declarative/qml/qdeclarativecustomparser.cpp b/src/declarative/qml/qdeclarativecustomparser.cpp
index 472a883..97a6a00 100644
--- a/src/declarative/qml/qdeclarativecustomparser.cpp
+++ b/src/declarative/qml/qdeclarativecustomparser.cpp
@@ -295,4 +295,14 @@ int QDeclarativeCustomParser::evaluateEnum(const QByteArray& script) const
return compiler->evaluateEnum(script);
}
+/*!
+ Resolves \a name to a type, or 0 if it is not a type. This can be used
+ to type-check object nodes.
+*/
+const QMetaObject *QDeclarativeCustomParser::resolveType(const QByteArray& name) const
+{
+ return compiler->resolveType(name);
+}
+
+
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecustomparser_p.h b/src/declarative/qml/qdeclarativecustomparser_p.h
index 0e397c5..509e30a 100644
--- a/src/declarative/qml/qdeclarativecustomparser_p.h
+++ b/src/declarative/qml/qdeclarativecustomparser_p.h
@@ -113,10 +113,18 @@ private:
class Q_DECLARATIVE_EXPORT QDeclarativeCustomParser
{
public:
- QDeclarativeCustomParser() : compiler(0), object(0) {}
+ enum Flag {
+ NoFlag = 0x00000000,
+ AcceptsAttachedProperties = 0x00000001
+ };
+ Q_DECLARE_FLAGS(Flags, Flag);
+
+ QDeclarativeCustomParser() : compiler(0), object(0), m_flags(NoFlag) {}
+ QDeclarativeCustomParser(Flags f) : compiler(0), object(0), m_flags(f) {}
virtual ~QDeclarativeCustomParser() {}
void clearErrors();
+ Flags flags() const { return m_flags; }
virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &)=0;
virtual void setCustomData(QObject *, const QByteArray &)=0;
@@ -130,12 +138,16 @@ protected:
int evaluateEnum(const QByteArray&) const;
+ const QMetaObject *resolveType(const QByteArray&) const;
+
private:
QList<QDeclarativeError> exceptions;
QDeclarativeCompiler *compiler;
QDeclarativeParser::Object *object;
+ Flags m_flags;
friend class QDeclarativeCompiler;
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeCustomParser::Flags);
#if 0
#define QML_REGISTER_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 86053c4..8b15ae9 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -1033,6 +1033,17 @@ QDeclarativeContextData *QDeclarativeEnginePrivate::getContext(QScriptContext *c
return contextClass->contextFromValue(scopeNode);
}
+/*!
+ Returns the QUrl associated with the script \a ctxt for the case that there is
+ no QDeclarativeContext.
+*/
+QUrl QDeclarativeEnginePrivate::getUrl(QScriptContext *ctxt)
+{
+ QScriptValue scopeNode = QScriptDeclarativeClass::scopeChainValue(ctxt, -3);
+ Q_ASSERT(scopeNode.isValid());
+ Q_ASSERT(QScriptDeclarativeClass::scriptClass(scopeNode) == contextClass);
+ return contextClass->urlFromValue(scopeNode);
+}
QString QDeclarativeEnginePrivate::urlToLocalFileOrQrc(const QUrl& url)
{
@@ -1075,16 +1086,19 @@ QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QS
static_cast<QDeclarativeScriptEngine*>(engine)->p;
QDeclarativeEngine* activeEngine = activeEnginePriv->q_func();
- QDeclarativeContextData* context = activeEnginePriv->getContext(ctxt);
- Q_ASSERT(context);
-
if(ctxt->argumentCount() != 1) {
return ctxt->throwError(QLatin1String("Qt.createComponent(): Invalid arguments"));
- }else{
+ } else {
+
QString arg = ctxt->argument(0).toString();
if (arg.isEmpty())
return engine->nullValue();
- QUrl url = QUrl(context->resolvedUrl(QUrl(arg)));
+ QUrl url;
+ QDeclarativeContextData* context = activeEnginePriv->getContext(ctxt);
+ if (context)
+ url = QUrl(context->resolvedUrl(QUrl(arg)));
+ else
+ url = activeEnginePriv->getUrl(ctxt).resolved(QUrl(arg));
QDeclarativeComponent *c = new QDeclarativeComponent(activeEngine, url, activeEngine);
QDeclarativeComponentPrivate::get(c)->creationContext = context;
QDeclarativeData::get(c, true)->setImplicitDestructible();
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index 3269e98..cfa9d73 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -315,6 +315,7 @@ public:
static QDeclarativeEnginePrivate *get(QScriptEngine *e) { return static_cast<QDeclarativeScriptEngine*>(e)->p; }
static QDeclarativeEngine *get(QDeclarativeEnginePrivate *p) { return p->q_func(); }
QDeclarativeContextData *getContext(QScriptContext *);
+ QUrl getUrl(QScriptContext *);
static QString urlToLocalFileOrQrc(const QUrl& url);
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index 7ae0050..d765649 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
QList<QDeclarativeEngine *> QDeclarativeEngineDebugServer::m_engines;
QDeclarativeEngineDebugServer::QDeclarativeEngineDebugServer(QObject *parent)
: QDeclarativeDebugService(QLatin1String("QDeclarativeEngine"), parent),
- m_watch(new QDeclarativeWatcher(this))
+ m_watch(new QDeclarativeWatcher(this))
{
QObject::connect(m_watch, SIGNAL(propertyChanged(int,int,QMetaProperty,QVariant)),
this, SLOT(propertyChanged(int,int,QMetaProperty,QVariant)));
@@ -99,6 +99,29 @@ QDataStream &operator>>(QDataStream &ds,
return ds;
}
+static inline bool isSignalPropertyName(const QString &signalName)
+{
+ // see QmlCompiler::isSignalPropertyName
+ return signalName.length() >= 3 && signalName.startsWith(QLatin1String("on")) &&
+ signalName.at(2).isLetter() && signalName.at(2).isUpper();
+}
+
+static bool hasValidSignal(QObject *object, const QString &propertyName)
+{
+ if (!isSignalPropertyName(propertyName))
+ return false;
+
+ QString signalName = propertyName.mid(2);
+ signalName[0] = signalName.at(0).toLower();
+
+ int sigIdx = QDeclarativePropertyPrivate::findSignalByName(object->metaObject(), signalName.toLatin1()).methodIndex();
+
+ if (sigIdx == -1)
+ return false;
+
+ return true;
+}
+
QDeclarativeEngineDebugServer::QDeclarativeObjectProperty
QDeclarativeEngineDebugServer::propertyData(QObject *obj, int propIdx)
{
@@ -396,7 +419,6 @@ void QDeclarativeEngineDebugServer::messageReceived(const QByteArray &message)
QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("WATCH_EXPR_OBJECT_R") << queryId << ok;
-
sendMessage(reply);
} else if (type == "NO_WATCH") {
int queryId;
@@ -430,7 +452,48 @@ void QDeclarativeEngineDebugServer::messageReceived(const QByteArray &message)
rs << QByteArray("EVAL_EXPRESSION_R") << queryId << result;
sendMessage(reply);
+ } else if (type == "SET_BINDING") {
+ int queryId;
+ int objectId;
+ QString propertyName;
+ QVariant expr;
+ bool isLiteralValue;
+ ds >> queryId >> objectId >> propertyName >> expr >> isLiteralValue;
+ setBinding(objectId, propertyName, expr, isLiteralValue);
+ }
+}
+
+void QDeclarativeEngineDebugServer::setBinding(int objectId,
+ const QString &propertyName,
+ const QVariant &expression,
+ bool isLiteralValue)
+{
+ QObject *object = objectForId(objectId);
+ QDeclarativeContext *context = qmlContext(object);
+
+ if (object && context) {
+
+ if (isLiteralValue) {
+ QDeclarativeProperty literalProperty(object, propertyName, context);
+ literalProperty.write(expression);
+ } else {
+ if (hasValidSignal(object, propertyName)) {
+ QDeclarativeProperty property(object, propertyName);
+ QDeclarativeExpression *declarativeExpression = new QDeclarativeExpression(context, object, expression.toString());
+ QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression);
+ } else {
+ QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context);
+ QDeclarativeProperty property(object, propertyName);
+ binding->setTarget(property);
+ binding->setNotifyOnValueChanged(true);
+ QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding);
+ if (oldBinding)
+ oldBinding->destroy();
+ binding->update();
+ }
+ }
}
+
}
void QDeclarativeEngineDebugServer::propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value)
diff --git a/src/declarative/qml/qdeclarativeenginedebug_p.h b/src/declarative/qml/qdeclarativeenginedebug_p.h
index 9491411..b3c23bd 100644
--- a/src/declarative/qml/qdeclarativeenginedebug_p.h
+++ b/src/declarative/qml/qdeclarativeenginedebug_p.h
@@ -107,6 +107,7 @@ private:
QDeclarativeObjectData objectData(QObject *);
QDeclarativeObjectProperty propertyData(QObject *, int);
QVariant valueContents(const QVariant &defaultValue) const;
+ void setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue);
static QList<QDeclarativeEngine *> m_engines;
QDeclarativeWatcher *m_watch;
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
index 39ea101..d43443d 100644
--- a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
@@ -41,6 +41,7 @@
#include "private/qdeclarativeglobalscriptclass_p.h"
+#include <QtCore/qstringlist.h>
#include <QtCore/qvector.h>
#include <QtScript/qscriptstring.h>
#include <QtScript/qscriptengine.h>
@@ -57,6 +58,7 @@ QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(QScriptEngine *engi
: QScriptClass(engine)
{
QString eval = QLatin1String("eval");
+ QString version = QLatin1String("version");
QScriptValue originalGlobalObject = engine->globalObject();
@@ -72,6 +74,9 @@ QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(QScriptEngine *engi
QString name = iter.name();
+ if (name == version)
+ continue;
+
if (name != eval) {
names.append(name);
values.append(iter.value());
@@ -98,18 +103,7 @@ QDeclarativeGlobalScriptClass::queryProperty(const QScriptValue &object,
Q_UNUSED(name);
Q_UNUSED(flags);
Q_UNUSED(id);
- return HandlesReadAccess | HandlesWriteAccess;
-}
-
-QScriptValue
-QDeclarativeGlobalScriptClass::property(const QScriptValue &object,
- const QScriptString &name,
- uint id)
-{
- Q_UNUSED(object);
- Q_UNUSED(name);
- Q_UNUSED(id);
- return engine()->undefinedValue();
+ return HandlesWriteAccess;
}
void QDeclarativeGlobalScriptClass::setProperty(QScriptValue &object,
@@ -125,8 +119,9 @@ void QDeclarativeGlobalScriptClass::setProperty(QScriptValue &object,
}
/* This method is for the use of tst_qdeclarativeecmascript::callQtInvokables() only */
-void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, const QScriptValue &value)
+void QDeclarativeGlobalScriptClass::explicitSetProperty(const QStringList &names, const QList<QScriptValue> &values)
{
+ Q_ASSERT(names.count() == values.count());
QScriptValue globalObject = engine()->globalObject();
QScriptValue v = engine()->newObject();
@@ -137,7 +132,12 @@ void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, con
v.setProperty(iter.scriptName(), iter.value());
}
- v.setProperty(name, value);
+ for (int ii = 0; ii < names.count(); ++ii) {
+ const QString &name = names.at(ii);
+ const QScriptValue &value = values.at(ii);
+ 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 414bf02..b42b7bd 100644
--- a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
@@ -67,13 +67,10 @@ public:
const QScriptString &name,
QueryFlags flags, uint *id);
- virtual QScriptValue property(const QScriptValue &object,
- const QScriptString &name, uint id);
-
virtual void setProperty(QScriptValue &object, const QScriptString &name,
uint id, const QScriptValue &value);
- void explicitSetProperty(const QString &, const QScriptValue &);
+ void explicitSetProperty(const QStringList &, const QList<QScriptValue> &);
const QScriptValue &staticGlobalObject() const { return m_staticGlobalObject; }
diff --git a/src/declarative/qml/qdeclarativeimageprovider.cpp b/src/declarative/qml/qdeclarativeimageprovider.cpp
index 4be3472..f4a8588 100644
--- a/src/declarative/qml/qdeclarativeimageprovider.cpp
+++ b/src/declarative/qml/qdeclarativeimageprovider.cpp
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
\note the request() method may be called by multiple threads, so ensure the
implementation of this method is reentrant.
- \sa QDeclarativeEngine::addImageProvider()
+ \sa QDeclarativeEngine::addImageProvider(), {declarative/cppextensions/imageprovider}{ImageProvider example}
*/
/*!
diff --git a/src/declarative/qml/qdeclarativelist.cpp b/src/declarative/qml/qdeclarativelist.cpp
index 31ef4c2..7c89672 100644
--- a/src/declarative/qml/qdeclarativelist.cpp
+++ b/src/declarative/qml/qdeclarativelist.cpp
@@ -341,6 +341,8 @@ QML list properties are typesafe - in this case \c {Fruit} is a QObject type tha
\note QDeclarativeListProperty can only be used for lists of QObject-derived object pointers.
+\sa {Object and List Property Types}
+
*/
/*!
diff --git a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp
index 399831d..d22798d 100644
--- a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp
+++ b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
Note: the create() method may be called by multiple threads, so ensure the
implementation of this method is reentrant.
- \sa QDeclarativeEngine::setNetworkAccessManagerFactory()
+ \sa QDeclarativeEngine::setNetworkAccessManagerFactory(), {declarative/cppextensions/networkaccessmanagerfactory}{NetworkAccessManagerFactory example}
*/
/*!
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
index aca01b2..3af892d 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
@@ -797,6 +797,26 @@ QScriptDeclarativeClass::Value MetaCallArgument::toValue(QDeclarativeEngine *e)
}
}
+int QDeclarativeObjectMethodScriptClass::enumType(const QMetaObject *meta, const QString &strname)
+{
+ QByteArray str = strname.toUtf8();
+ QByteArray scope;
+ QByteArray name;
+ int scopeIdx = str.lastIndexOf("::");
+ if (scopeIdx != -1) {
+ scope = str.left(scopeIdx);
+ name = str.mid(scopeIdx + 2);
+ } else {
+ name = str;
+ }
+ for (int i = meta->enumeratorCount() - 1; i >= 0; --i) {
+ QMetaEnum m = meta->enumerator(i);
+ if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope)))
+ return QVariant::Int;
+ }
+ return QVariant::Invalid;
+}
+
QDeclarativeObjectMethodScriptClass::Value QDeclarativeObjectMethodScriptClass::call(Object *o, QScriptContext *ctxt)
{
MethodData *method = static_cast<MethodData *>(o);
@@ -810,7 +830,9 @@ QDeclarativeObjectMethodScriptClass::Value QDeclarativeObjectMethodScriptClass::
// ### Cache
for (int ii = 0; ii < argTypeNames.count(); ++ii) {
argTypes[ii] = QMetaType::type(argTypeNames.at(ii));
- if (argTypes[ii] == QVariant::Invalid)
+ if (argTypes[ii] == QVariant::Invalid)
+ argTypes[ii] = enumType(method->object->metaObject(), argTypeNames.at(ii));
+ if (argTypes[ii] == QVariant::Invalid)
return Value(ctxt, ctxt->throwError(QString::fromLatin1("Unknown method parameter type: %1").arg(QLatin1String(argTypeNames.at(ii)))));
}
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
index 4b27e53..75e384c 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
@@ -80,6 +80,8 @@ protected:
virtual Value property(Object *, const Identifier &);
private:
+ int enumType(const QMetaObject *, const QString &);
+
PersistentIdentifier m_connectId;
PersistentIdentifier m_disconnectId;
QScriptValue m_connect;
diff --git a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
index 2a3417a..764a8db 100644
--- a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
+++ b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
@@ -107,8 +107,7 @@ QDeclarativeTypeNameScriptClass::queryProperty(Object *obj, const Identifier &na
return 0;
}
- } else {
- Q_ASSERT(data->type);
+ } else if (data->type) {
QString strName = toString(name);
@@ -134,6 +133,7 @@ QDeclarativeTypeNameScriptClass::queryProperty(Object *obj, const Identifier &na
if (!object) return 0;
return ep->objectClass->queryProperty(object, name, flags, 0);
}
+
}
return 0;