summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-08-25 22:57:29 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-08-25 22:57:29 (GMT)
commit314c6ec54e4cb4e2ec936ada7e0a112a60b87832 (patch)
treea5444e7cae8d40eb549b70dd4473057f6b3cda09 /src/declarative/qml
parent8e580cebef7128666017ba39d41aa620a1d2eddf (diff)
parent0094735947164aef8f8e6539c535199b29ed6f4e (diff)
downloadQt-314c6ec54e4cb4e2ec936ada7e0a112a60b87832.zip
Qt-314c6ec54e4cb4e2ec936ada7e0a112a60b87832.tar.gz
Qt-314c6ec54e4cb4e2ec936ada7e0a112a60b87832.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qmlbindingoptimizations.cpp12
-rw-r--r--src/declarative/qml/qmlbindingoptimizations_p.h5
-rw-r--r--src/declarative/qml/qmlcompiler.cpp60
-rw-r--r--src/declarative/qml/qmlcompiler_p.h5
-rw-r--r--src/declarative/qml/qmlcompositetypemanager.cpp26
-rw-r--r--src/declarative/qml/qmldom.cpp7
-rw-r--r--src/declarative/qml/qmlengine.cpp165
-rw-r--r--src/declarative/qml/qmlengine_p.h32
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp2
-rw-r--r--src/declarative/qml/qmlvaluetype.cpp81
-rw-r--r--src/declarative/qml/qmlvaluetype_p.h18
11 files changed, 268 insertions, 145 deletions
diff --git a/src/declarative/qml/qmlbindingoptimizations.cpp b/src/declarative/qml/qmlbindingoptimizations.cpp
index e1f4a90..e4ca358 100644
--- a/src/declarative/qml/qmlbindingoptimizations.cpp
+++ b/src/declarative/qml/qmlbindingoptimizations.cpp
@@ -64,6 +64,11 @@ QmlBinding_Id::QmlBinding_Id(QObject *object, int propertyIdx,
QmlAbstractExpression::setContext(context);
}
+QmlBinding_Id::~QmlBinding_Id()
+{
+ removeFromContext();
+}
+
void QmlBinding_Id::setEnabled(bool e)
{
if (e) {
@@ -103,7 +108,7 @@ void QmlBinding_Id::update()
}
}
-void QmlBinding_Id::reset()
+void QmlBinding_Id::removeFromContext()
{
if (m_prev) {
*m_prev = m_next;
@@ -111,6 +116,11 @@ void QmlBinding_Id::reset()
m_next = 0;
m_prev = 0;
}
+}
+
+void QmlBinding_Id::reset()
+{
+ removeFromContext();
QObject *o = 0;
void *a[] = { &o, 0 };
diff --git a/src/declarative/qml/qmlbindingoptimizations_p.h b/src/declarative/qml/qmlbindingoptimizations_p.h
index 2d2ffec..ab264c7 100644
--- a/src/declarative/qml/qmlbindingoptimizations_p.h
+++ b/src/declarative/qml/qmlbindingoptimizations_p.h
@@ -65,7 +65,8 @@ class QmlBinding_Id : public QmlAbstractExpression,
{
public:
QmlBinding_Id(QObject *object, int propertyIdx,
- QmlContext *context, int id);
+ QmlContext *context, int id);
+ virtual ~QmlBinding_Id();
// Inherited from QmlAbstractBinding
virtual void setEnabled(bool);
@@ -75,6 +76,8 @@ public:
void reset();
private:
+ void removeFromContext();
+
QmlBinding_Id **m_prev;
QmlBinding_Id *m_next;
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 1771cb4..bbcc64d 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -1176,11 +1176,19 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop,
}
QmlType *type = 0;
- QmlEnginePrivate::get(engine)->resolveType(unit->imports, prop->name, &type, 0);
- // 0: attached properties not supported in QML component files
-
- if (!type || !type->attachedPropertiesType())
+ QmlEnginePrivate::ImportedNamespace *typeNamespace = 0;
+ QmlEnginePrivate::get(engine)->resolveType(unit->imports, prop->name,
+ &type, 0, 0, 0, &typeNamespace);
+
+ if (typeNamespace) {
+ // ### We might need to indicate that this property is a namespace
+ // for the DOM API
+ COMPILE_CHECK(buildPropertyInNamespace(typeNamespace, prop, obj,
+ ctxt));
+ return true;
+ } else if (!type || !type->attachedPropertiesType()) {
COMPILE_EXCEPTION(prop, "Non-existant attached object");
+ }
if (!prop->value)
COMPILE_EXCEPTION(prop, "Invalid attached object assignment");
@@ -1265,6 +1273,40 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop,
return true;
}
+bool
+QmlCompiler::buildPropertyInNamespace(QmlEnginePrivate::ImportedNamespace *ns,
+ QmlParser::Property *nsProp,
+ QmlParser::Object *obj,
+ const BindingContext &ctxt)
+{
+ if (!nsProp->value)
+ COMPILE_EXCEPTION(nsProp, "Invalid use of namespace");
+
+ foreach (Property *prop, nsProp->value->properties) {
+
+ if (!isAttachedPropertyName(prop->name))
+ COMPILE_EXCEPTION(prop, "Not an attached property name");
+
+ // Setup attached property data
+
+ QmlType *type = 0;
+ QmlEnginePrivate::get(engine)->resolveTypeInNamespace(ns, prop->name,
+ &type, 0, 0, 0);
+
+ if (!type || !type->attachedPropertiesType())
+ COMPILE_EXCEPTION(prop, "Non-existant attached object");
+
+ if (!prop->value)
+ COMPILE_EXCEPTION(prop, "Invalid attached object assignment");
+
+ Q_ASSERT(type->attachedPropertiesFunction());
+ prop->index = type->index();
+ prop->value->metatype = type->attachedPropertiesType();
+
+ COMPILE_CHECK(buildAttachedProperty(prop, obj, ctxt));
+ }
+}
+
void QmlCompiler::genValueProperty(QmlParser::Property *prop,
QmlParser::Object *obj)
{
@@ -1407,11 +1449,19 @@ bool QmlCompiler::buildIdProperty(QmlParser::Property *prop,
prop->values.at(0)->object)
COMPILE_EXCEPTION(prop, "Invalid use of id property");
- QString val = prop->values.at(0)->primitive();
+ QmlParser::Value *idValue = prop->values.at(0);
+ QString val = idValue->primitive();
if (!isValidId(val))
COMPILE_EXCEPTION(prop, val << "is not a valid object id");
+ // We disallow id's that conflict with import prefixes
+ QmlEnginePrivate::ImportedNamespace *ns = 0;
+ QmlEnginePrivate::get(engine)->resolveType(unit->imports, val.toUtf8(),
+ 0, 0, 0, 0, &ns);
+ if (ns)
+ COMPILE_EXCEPTION(idValue, "id conflicts with namespace prefix");
+
if (compileState.ids.contains(val))
COMPILE_EXCEPTION(prop, "id is not unique");
diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h
index 58279c4..c42c2d9 100644
--- a/src/declarative/qml/qmlcompiler_p.h
+++ b/src/declarative/qml/qmlcompiler_p.h
@@ -60,6 +60,7 @@
#include <private/qmlinstruction_p.h>
#include <private/qmlcompositetypemanager_p.h>
#include <private/qmlparser_p.h>
+#include <private/qmlengine_p.h>
QT_BEGIN_NAMESPACE
@@ -165,6 +166,10 @@ private:
const BindingContext &);
bool buildProperty(QmlParser::Property *prop, QmlParser::Object *obj,
const BindingContext &);
+ bool buildPropertyInNamespace(QmlEnginePrivate::ImportedNamespace *ns,
+ QmlParser::Property *prop,
+ QmlParser::Object *obj,
+ const BindingContext &);
bool buildIdProperty(QmlParser::Property *prop, QmlParser::Object *obj);
bool buildAttachedProperty(QmlParser::Property *prop,
QmlParser::Object *obj,
diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp
index 5bf2dc0..1b1f67c 100644
--- a/src/declarative/qml/qmlcompositetypemanager.cpp
+++ b/src/declarative/qml/qmlcompositetypemanager.cpp
@@ -327,26 +327,18 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit)
}
QUrl url;
- QmlEnginePrivate::ImportedNamespace *s;
- QByteArray localTypeName;
-
- QmlEnginePrivate::get(engine)->resolveNamespace(unit->imports, typeName, &s, &localTypeName);
- if (QmlEnginePrivate::get(engine)->resolveTypeInNamespace(s, localTypeName, &ref.type, &url)) {
- int majorVersion;
- int minorVersion;
- if (s->getTypeInfo(localTypeName, 0, &majorVersion, &minorVersion)) {
- foreach (QmlParser::Object *obj, parserRef->refObjects) {
- // store namespace for DOM
- obj->majorVersion = majorVersion;
- obj->minorVersion = minorVersion;
- }
- }
- } else {
- // try base url
- url = unit->imports.baseUrl().resolved(QUrl(QLatin1String(typeName + ".qml")));
+ int majorVersion;
+ int minorVersion;
+ if (!QmlEnginePrivate::get(engine)->resolveType(unit->imports, typeName, &ref.type, &url, &majorVersion, &minorVersion, 0)) {
+ // XXX could produce error message here.
}
if (ref.type) {
+ foreach (QmlParser::Object *obj, parserRef->refObjects) {
+ // store namespace for DOM
+ obj->majorVersion = majorVersion;
+ obj->minorVersion = minorVersion;
+ }
unit->types << ref;
continue;
}
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp
index 2aaf492..9e12485 100644
--- a/src/declarative/qml/qmldom.cpp
+++ b/src/declarative/qml/qmldom.cpp
@@ -765,8 +765,11 @@ Text { id: MyText }
*/
QString QmlDomObject::objectId() const
{
- if (d->object) return d->object->id;
- else return QByteArray();
+ if (d->object) {
+ return d->object->id;
+ } else {
+ return QString();
+ }
}
/*!
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index fd18b26..7923eda 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -1072,7 +1072,7 @@ void QmlObjectScriptClass::setProperty(QScriptValue &object,
}
-struct QmlImportedNamespacePrivate {
+struct QmlEnginePrivate::ImportedNamespace {
QStringList urls;
QList<int> majversions;
QList<int> minversions;
@@ -1122,7 +1122,7 @@ struct QmlImportedNamespacePrivate {
return QUrl();
}
- QmlType *findBuiltin(const QByteArray& type, QByteArray* found=0) const
+ QmlType *findBuiltin(const QByteArray& type, int *vmajor, int *vminor) const
{
for (int i=0; i<urls.count(); ++i) {
int vmaj = majversions.at(i);
@@ -1131,7 +1131,8 @@ struct QmlImportedNamespacePrivate {
qt += "/";
qt += type;
QmlType *t = QmlMetaType::qmlType(qt,vmaj,vmin);
- if (found) *found = qt;
+ if (vmajor) *vmajor = vmaj;
+ if (vminor) *vminor = vmin;
if (t) return t;
}
return 0;
@@ -1140,6 +1141,16 @@ struct QmlImportedNamespacePrivate {
class QmlImportsPrivate {
public:
+ QmlImportsPrivate() : ref(1)
+ {
+ }
+
+ ~QmlImportsPrivate()
+ {
+ foreach (QmlEnginePrivate::ImportedNamespace* s, set.values())
+ delete s;
+ }
+
bool add(const QUrl& base, const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType, const QStringList& importPath)
{
QmlEnginePrivate::ImportedNamespace *s;
@@ -1177,10 +1188,10 @@ public:
} else {
url = base.resolved(QUrl(url)).toString();
}
- s->d->urls.append(url);
- s->d->majversions.append(vmaj);
- s->d->minversions.append(vmin);
- s->d->isLibrary.append(importType == QmlScriptParser::Import::Library);
+ s->urls.append(url);
+ s->majversions.append(vmaj);
+ s->minversions.append(vmin);
+ s->isLibrary.append(importType == QmlScriptParser::Import::Library);
return true;
}
@@ -1202,13 +1213,13 @@ public:
}
QString unqualifiedtype = type.mid(slash+1);
if (s)
- return s->d->find(unqualifiedtype);
+ return s->find(unqualifiedtype);
else
return QUrl();
}
- QmlType *findBuiltin(const QByteArray& type, QByteArray* found=0)
+ QmlType *findBuiltin(const QByteArray& type, int *vmajor, int *vminor)
{
QmlEnginePrivate::ImportedNamespace *s = 0;
int slash = type.indexOf('/');
@@ -1226,42 +1237,39 @@ public:
}
QByteArray unqualifiedtype = slash < 0 ? type : type.mid(slash+1); // common-case opt (QString::mid works fine, but slower)
if (s)
- return s->d->findBuiltin(unqualifiedtype,found);
+ return s->findBuiltin(unqualifiedtype,vmajor,vminor);
else
return 0;
- }
+ }
QmlEnginePrivate::ImportedNamespace *findNamespace(const QString& type)
{
return set.value(type);
}
- void resolveNamespace(const QByteArray &type, QmlEnginePrivate::ImportedNamespace **ns, QByteArray *unqualifiedType)
- {
- QmlEnginePrivate::ImportedNamespace *s = 0;
- int slash = type.indexOf('/');
- if (slash >= 0) {
- while (!s) {
- s = set.value(QString::fromLatin1(type.left(slash)));
- int nslash = type.indexOf('/',slash+1);
- if (nslash > 0)
- slash = nslash;
- else
- break;
- }
- } else {
- s = &unqualifiedset;
- }
-
- *ns = s;
- *unqualifiedType = slash < 0 ? type : type.mid(slash+1); // common-case opt (QString::mid works fine, but slower)
- }
+ QUrl base;
+ int ref;
private:
QmlEnginePrivate::ImportedNamespace unqualifiedset;
QHash<QString,QmlEnginePrivate::ImportedNamespace* > set;
};
+QmlEnginePrivate::Imports::Imports(const Imports &copy) :
+ d(copy.d)
+{
+ ++d->ref;
+}
+
+QmlEnginePrivate::Imports &QmlEnginePrivate::Imports::operator =(const Imports &copy)
+{
+ ++copy.d->ref;
+ if (--d->ref == 0)
+ delete d;
+ d = copy.d;
+ return *this;
+}
+
QmlEnginePrivate::Imports::Imports() :
d(new QmlImportsPrivate)
{
@@ -1269,6 +1277,8 @@ QmlEnginePrivate::Imports::Imports() :
QmlEnginePrivate::Imports::~Imports()
{
+ if (--d->ref == 0)
+ delete d;
}
/*!
@@ -1276,38 +1286,15 @@ QmlEnginePrivate::Imports::~Imports()
*/
void QmlEnginePrivate::Imports::setBaseUrl(const QUrl& url)
{
- base = url;
-}
-
-QmlEnginePrivate::ImportedNamespace::ImportedNamespace()
- : d(new QmlImportedNamespacePrivate)
-{
-}
-
-QmlEnginePrivate::ImportedNamespace::~ImportedNamespace()
-{
- delete d;
+ d->base = url;
}
-bool QmlEnginePrivate::ImportedNamespace::getTypeInfo(const QByteArray &typeName, QString *uri, int *majorVersion, int *minorVersion)
+/*!
+ Returns the base URL to be used for all relative file imports added.
+*/
+QUrl QmlEnginePrivate::Imports::baseUrl() const
{
- for (int i=0; i<d->urls.count(); ++i) {
- int vmaj = d->majversions.at(i);
- int vmin = d->minversions.at(i);
- QByteArray qt = d->urls.at(i).toLatin1();
- qt += "/";
- qt += typeName;
- if (QmlMetaType::qmlType(qt,vmaj,vmin)) {
- if (uri)
- *uri = d->urls.at(i);
- if (majorVersion)
- *majorVersion = d->majversions.at(i);
- if (minorVersion)
- *minorVersion = d->minversions.at(i);
- return true;
- }
- }
- return false;
+ return d->base;
}
/*!
@@ -1344,7 +1331,7 @@ void QmlEngine::addImportPath(const QString& path)
*/
bool QmlEnginePrivate::addToImport(Imports* imports, const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType) const
{
- bool ok = imports->d->add(imports->base,uri,prefix,vmaj,vmin,importType,fileImportPath);
+ bool ok = imports->d->add(imports->d->base,uri,prefix,vmaj,vmin,importType,fileImportPath);
if (qmlImportTrace())
qDebug() << "QmlEngine::addToImport(" << imports << uri << prefix << vmaj << "." << vmin << (importType==QmlScriptParser::Import::Library? "Library" : "File") << ": " << ok;
return ok;
@@ -1362,11 +1349,21 @@ bool QmlEnginePrivate::addToImport(Imports* imports, const QString& uri, const Q
\sa addToImport()
*/
-bool QmlEnginePrivate::resolveType(const Imports& imports, const QByteArray& type, QmlType** type_return, QUrl* url_return, ImportedNamespace** ns_return) const
+bool QmlEnginePrivate::resolveType(const Imports& imports, const QByteArray& type, QmlType** type_return, QUrl* url_return, int *vmaj, int *vmin, ImportedNamespace** ns_return) const
{
+ if (ns_return) {
+ *ns_return = imports.d->findNamespace(QLatin1String(type));
+ if (*ns_return)
+ return true;
+ }
if (type_return) {
- QmlType* t = imports.d->findBuiltin(type);
- if (!t) t = QmlMetaType::qmlType(type,0,0); // Try global namespace
+ QmlType* t = imports.d->findBuiltin(type,vmaj,vmin);
+ if (!t) {
+ // XXX do we really still need this?
+ t = QmlMetaType::qmlType(type,0,0); // Try global namespace
+ if (vmin) *vmin = 0;
+ if (vmaj) *vmaj = 0;
+ }
if (t) {
if (type_return) *type_return = t;
if (qmlImportTrace())
@@ -1377,7 +1374,7 @@ bool QmlEnginePrivate::resolveType(const Imports& imports, const QByteArray& typ
if (url_return) {
QUrl url = imports.d->find(QLatin1String(type));
if (!url.isValid())
- url = imports.base.resolved(QUrl(QLatin1String(type + ".qml")));
+ url = imports.d->base.resolved(QUrl(QLatin1String(type + ".qml")));
if (url.isValid()) {
if (url_return) *url_return = url;
@@ -1386,11 +1383,6 @@ bool QmlEnginePrivate::resolveType(const Imports& imports, const QByteArray& typ
return true;
}
}
- if (ns_return) {
- *ns_return = imports.d->findNamespace(QLatin1String(type));
- if (*ns_return)
- return true;
- }
if (qmlImportTrace())
qDebug() << "QmlEngine::resolveType" << type << " not found";
return false;
@@ -1399,16 +1391,6 @@ bool QmlEnginePrivate::resolveType(const Imports& imports, const QByteArray& typ
/*!
\internal
- Splits a fully qualified type name into the namespace and the unqualified type name.
-*/
-void QmlEnginePrivate::resolveNamespace(const Imports& imports, const QByteArray &type, ImportedNamespace **ns, QByteArray *unqualifiedType) const
-{
- imports.d->resolveNamespace(type, ns, unqualifiedType);
-}
-
-/*!
- \internal
-
Searching \e only in the namespace \a ns (previously returned in a call to
resolveType(), \a type is found and returned to either
a QmlType stored at \a type_return, or
@@ -1416,31 +1398,14 @@ void QmlEnginePrivate::resolveNamespace(const Imports& imports, const QByteArray
If either return pointer is 0, the corresponding search is not done.
*/
-bool QmlEnginePrivate::resolveTypeInNamespace(ImportedNamespace* ns, const QByteArray& type, QmlType** type_return, QUrl* url_return ) const
+void QmlEnginePrivate::resolveTypeInNamespace(ImportedNamespace* ns, const QByteArray& type, QmlType** type_return, QUrl* url_return, int *vmaj, int *vmin ) const
{
- if (!ns)
- return false;
-
if (type_return) {
- QmlType* t = ns->d->findBuiltin(type);
- if (!t) t = QmlMetaType::qmlType(type,0,0); // Try global namespace
- if (t) {
- *type_return = t;
- if (qmlImportTrace())
- qDebug() << "QmlEngine::resolveTypeInNamespace" << type << "= (builtin)";
- return true;
- }
+ *type_return = ns->findBuiltin(type,vmaj,vmin);
}
if (url_return) {
- QUrl url = ns->d->find(QLatin1String(type));
- if (url.isValid()) {
- if (url_return) *url_return = url;
- if (qmlImportTrace())
- qDebug() << "QmlEngine::resolveType" << type << "=" << url;
- return true;
- }
+ *url_return = ns->find(QLatin1String(type));
}
- return false;
}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index c84b3b5..53b2967 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -188,31 +188,26 @@ public:
struct Imports {
Imports();
~Imports();
- void setBaseUrl(const QUrl& url);
- QUrl baseUrl() const { return base; }
- private:
- friend class QmlEnginePrivate;
- QUrl base;
- QmlImportsPrivate *d;
- };
+ Imports(const Imports &copy);
+ Imports &operator =(const Imports &copy);
- struct ImportedNamespace {
- ImportedNamespace();
- ~ImportedNamespace();
+ void setBaseUrl(const QUrl& url);
+ QUrl baseUrl() const;
- bool getTypeInfo(const QByteArray &typeName, QString *uri, int *vmaj, int *vmin);
private:
- friend class QmlImportsPrivate;
friend class QmlEnginePrivate;
- class QmlImportedNamespacePrivate *d;
+ QmlImportsPrivate *d;
};
+ struct ImportedNamespace;
bool addToImport(Imports*, const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType) const;
-
- bool resolveType(const Imports&, const QByteArray& type, QmlType** type_return, QUrl* url_return, ImportedNamespace** ns_return=0) const;
-
- void resolveNamespace(const Imports& imports, const QByteArray &type, ImportedNamespace **s, QByteArray *unqualifiedType) const;
- bool resolveTypeInNamespace(ImportedNamespace*, const QByteArray& type, QmlType** type_return, QUrl* url_return ) const;
+ bool resolveType(const Imports&, const QByteArray& type,
+ QmlType** type_return, QUrl* url_return,
+ int *version_major, int *version_minor,
+ ImportedNamespace** ns_return) const;
+ void resolveTypeInNamespace(ImportedNamespace*, const QByteArray& type,
+ QmlType** type_return, QUrl* url_return,
+ int *version_major, int *version_minor ) const;
static QScriptValue qmlScriptObject(QObject*, QmlEngine*);
@@ -224,6 +219,7 @@ public:
static QmlEnginePrivate *get(QmlEngine *e) { return e->d_func(); }
};
+
class QmlScriptClass : public QScriptClass
{
public:
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index 99f9f0c..cc5e4ee 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -224,7 +224,7 @@ void QmlMetaPropertyPrivate::initProperty(QObject *obj, const QString &name)
if (typeData) {
QmlType *t = 0;
- enginePrivate->resolveType(typeData->imports, name.toLatin1(), &t, 0);
+ enginePrivate->resolveType(typeData->imports, name.toLatin1(), &t, 0, 0, 0, 0);
if (t && t->attachedPropertiesFunction()) {
attachedFunc = t->index();
if (attachedFunc != -1)
diff --git a/src/declarative/qml/qmlvaluetype.cpp b/src/declarative/qml/qmlvaluetype.cpp
index 7af3c56..4ae2070 100644
--- a/src/declarative/qml/qmlvaluetype.cpp
+++ b/src/declarative/qml/qmlvaluetype.cpp
@@ -103,6 +103,16 @@ void QmlPointFValueType::write(QObject *obj, int idx)
QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
}
+QVariant QmlPointFValueType::value()
+{
+ return QVariant(point);
+}
+
+void QmlPointFValueType::setValue(QVariant value)
+{
+ point = qvariant_cast<QPointF>(value);
+}
+
qreal QmlPointFValueType::x() const
{
return point.x();
@@ -140,6 +150,16 @@ void QmlPointValueType::write(QObject *obj, int idx)
QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
}
+QVariant QmlPointValueType::value()
+{
+ return QVariant(point);
+}
+
+void QmlPointValueType::setValue(QVariant value)
+{
+ point = qvariant_cast<QPoint>(value);
+}
+
int QmlPointValueType::x() const
{
return point.x();
@@ -177,6 +197,16 @@ void QmlSizeFValueType::write(QObject *obj, int idx)
QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
}
+QVariant QmlSizeFValueType::value()
+{
+ return QVariant(size);
+}
+
+void QmlSizeFValueType::setValue(QVariant value)
+{
+ size = qvariant_cast<QSizeF>(value);
+}
+
qreal QmlSizeFValueType::width() const
{
return size.width();
@@ -214,6 +244,16 @@ void QmlSizeValueType::write(QObject *obj, int idx)
QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
}
+QVariant QmlSizeValueType::value()
+{
+ return QVariant(size);
+}
+
+void QmlSizeValueType::setValue(QVariant value)
+{
+ size = qvariant_cast<QSize>(value);
+}
+
int QmlSizeValueType::width() const
{
return size.width();
@@ -251,6 +291,16 @@ void QmlRectFValueType::write(QObject *obj, int idx)
QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
}
+QVariant QmlRectFValueType::value()
+{
+ return QVariant(rect);
+}
+
+void QmlRectFValueType::setValue(QVariant value)
+{
+ rect = qvariant_cast<QRectF>(value);
+}
+
qreal QmlRectFValueType::x() const
{
return rect.x();
@@ -308,6 +358,16 @@ void QmlRectValueType::write(QObject *obj, int idx)
QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
}
+QVariant QmlRectValueType::value()
+{
+ return QVariant(rect);
+}
+
+void QmlRectValueType::setValue(QVariant value)
+{
+ rect = qvariant_cast<QRect>(value);
+}
+
int QmlRectValueType::x() const
{
return rect.x();
@@ -365,6 +425,16 @@ void QmlVector3DValueType::write(QObject *obj, int idx)
QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
}
+QVariant QmlVector3DValueType::value()
+{
+ return QVariant(vector);
+}
+
+void QmlVector3DValueType::setValue(QVariant value)
+{
+ vector = qvariant_cast<QVector3D>(value);
+}
+
qreal QmlVector3DValueType::x() const
{
return vector.x();
@@ -412,6 +482,17 @@ void QmlFontValueType::write(QObject *obj, int idx)
QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
}
+QVariant QmlFontValueType::value()
+{
+ return QVariant(font);
+}
+
+void QmlFontValueType::setValue(QVariant value)
+{
+ font = qvariant_cast<QFont>(value);
+}
+
+
QString QmlFontValueType::family() const
{
return font.family();
diff --git a/src/declarative/qml/qmlvaluetype_p.h b/src/declarative/qml/qmlvaluetype_p.h
index 7a3620c..a56feec 100644
--- a/src/declarative/qml/qmlvaluetype_p.h
+++ b/src/declarative/qml/qmlvaluetype_p.h
@@ -68,6 +68,8 @@ public:
QmlValueType(QObject *parent = 0);
virtual void read(QObject *, int) = 0;
virtual void write(QObject *, int) = 0;
+ virtual QVariant value() = 0;
+ virtual void setValue(QVariant) = 0;
};
class QmlValueTypeFactory
@@ -91,6 +93,8 @@ public:
virtual void read(QObject *, int);
virtual void write(QObject *, int);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
qreal x() const;
qreal y() const;
@@ -111,6 +115,8 @@ public:
virtual void read(QObject *, int);
virtual void write(QObject *, int);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
int x() const;
int y() const;
@@ -131,6 +137,8 @@ public:
virtual void read(QObject *, int);
virtual void write(QObject *, int);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
qreal width() const;
qreal height() const;
@@ -151,6 +159,8 @@ public:
virtual void read(QObject *, int);
virtual void write(QObject *, int);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
int width() const;
int height() const;
@@ -173,6 +183,8 @@ public:
virtual void read(QObject *, int);
virtual void write(QObject *, int);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
qreal x() const;
qreal y() const;
@@ -200,6 +212,8 @@ public:
virtual void read(QObject *, int);
virtual void write(QObject *, int);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
int x() const;
int y() const;
@@ -226,6 +240,8 @@ public:
virtual void read(QObject *, int);
virtual void write(QObject *, int);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
qreal x() const;
qreal y() const;
@@ -252,6 +268,8 @@ public:
virtual void read(QObject *, int);
virtual void write(QObject *, int);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
QString family() const;
void setFamily(const QString &);