summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-08-27 05:17:37 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-08-27 05:17:37 (GMT)
commitfd2616977e5e03afa3be9b455bc0a6be19f9132f (patch)
treeb71404860117132253b7e76832adf28748ca81cb /src/declarative/qml
parent12f4fc296578fb30ac1bf690b3eeba176b72205a (diff)
parent219e2fa7ace74d87fda4ed8c3a2a75005fab10b9 (diff)
downloadQt-fd2616977e5e03afa3be9b455bc0a6be19f9132f.zip
Qt-fd2616977e5e03afa3be9b455bc0a6be19f9132f.tar.gz
Qt-fd2616977e5e03afa3be9b455bc0a6be19f9132f.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Conflicts: src/declarative/extra/qmlbehavior.cpp src/declarative/extra/qmlbehavior.h
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qml.h1
-rw-r--r--src/declarative/qml/qmlcompiler.cpp29
-rw-r--r--src/declarative/qml/qmlinstruction.cpp2
-rw-r--r--src/declarative/qml/qmlinstruction_p.h1
-rw-r--r--src/declarative/qml/qmlmetatype.cpp30
-rw-r--r--src/declarative/qml/qmlmetatype.h20
-rw-r--r--src/declarative/qml/qmlpropertyvaluesource.cpp22
-rw-r--r--src/declarative/qml/qmlpropertyvaluesource.h23
-rw-r--r--src/declarative/qml/qmlvme.cpp9
9 files changed, 62 insertions, 75 deletions
diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h
index bced8f2..23f2f1e 100644
--- a/src/declarative/qml/qml.h
+++ b/src/declarative/qml/qml.h
@@ -50,6 +50,7 @@
#include <QtDeclarative/qmlmetatype.h>
#include <QtDeclarative/qmlmetaproperty.h>
#include <QtDeclarative/qmlparserstatus.h>
+#include <QtDeclarative/qmlpropertyvaluesource.h>
#include <QtDeclarative/qmllist.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index b5edc38..764699e 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -1411,7 +1411,6 @@ void QmlCompiler::genPropertyAssignment(QmlParser::Property *prop,
}
} else if (v->type == Value::ValueSource) {
-
genObject(v->object);
QmlInstruction store;
@@ -1425,6 +1424,8 @@ void QmlCompiler::genPropertyAssignment(QmlParser::Property *prop,
QmlMetaPropertyPrivate::saveProperty(prop->index);
store.assignValueSource.owner = 0;
}
+ QmlType *valueType = QmlMetaType::qmlType(v->object->metatype);
+ store.assignValueSource.castValue = valueType->propertyValueSourceCast();
output->bytecode << store;
} else if (v->type == Value::PropertyBinding) {
@@ -1584,15 +1585,7 @@ bool QmlCompiler::buildValueTypeProperty(QObject *type,
Value *value = prop->values.at(0);
if (value->object) {
- const QMetaObject *c =
- output->types.at(value->object->type).metaObject();
- bool isPropertyValue = false;
- while (c && !isPropertyValue) {
- isPropertyValue =
- (c == &QmlPropertyValueSource::staticMetaObject);
- c = c->superClass();
- }
-
+ bool isPropertyValue = output->types.at(value->object->type).type->propertyValueSourceCast() != -1;
if (!isPropertyValue) {
COMPILE_EXCEPTION(prop, "Invalid property use");
} else {
@@ -1762,30 +1755,26 @@ bool QmlCompiler::buildPropertyObjectAssignment(QmlParser::Property *prop,
v->object->metatype = output->types.at(v->object->type).metaObject();
Q_ASSERT(v->object->metaObject());
+ // Will be true if the assigned type inherits QmlPropertyValueSource
+ bool isPropertyValue = false;
+ if (QmlType *valueType = QmlMetaType::qmlType(v->object->metatype))
+ isPropertyValue = valueType->propertyValueSourceCast() != -1;
+
// We want to raw metaObject here as the raw metaobject is the
// actual property type before we applied any extensions that might
// effect the properties on the type, but don't effect assignability
const QMetaObject *propertyMetaObject =
QmlMetaType::rawMetaObjectForType(prop->type);
- // Will be true if the assigned type inherits QmlPropertyValueSource
- bool isPropertyValue = false;
// Will be true if the assgned type inherits propertyMetaObject
bool isAssignable = false;
- // Determine isPropertyValue and isAssignable values
+ // Determine isAssignable value
if (propertyMetaObject) {
const QMetaObject *c = v->object->metatype;
while(c) {
- isPropertyValue |= (c == &QmlPropertyValueSource::staticMetaObject);
isAssignable |= (c == propertyMetaObject);
c = c->superClass();
}
- } else {
- const QMetaObject *c = v->object->metatype;
- while(!isPropertyValue && c) {
- isPropertyValue |= (c == &QmlPropertyValueSource::staticMetaObject);
- c = c->superClass();
- }
}
if (isAssignable) {
diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp
index 02e4883..b71c6e3 100644
--- a/src/declarative/qml/qmlinstruction.cpp
+++ b/src/declarative/qml/qmlinstruction.cpp
@@ -147,7 +147,7 @@ void QmlCompiledData::dump(QmlInstruction *instr, int idx)
qWarning() << idx << "\t" << line << "\t" << "STORE_COMPILED_BINDING\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t\t" << instr->assignBinding.context;
break;
case QmlInstruction::StoreValueSource:
- qWarning() << idx << "\t" << line << "\t" << "STORE_VALUE_SOURCE\t" << instr->assignValueSource.property;
+ qWarning() << idx << "\t" << line << "\t" << "STORE_VALUE_SOURCE\t" << instr->assignValueSource.property << "\t" << instr->assignValueSource.castValue;
break;
case QmlInstruction::BeginObject:
qWarning() << idx << "\t" << line << "\t" << "BEGIN\t\t\t" << instr->begin.castValue;
diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h
index 0f2995a..8861609a 100644
--- a/src/declarative/qml/qmlinstruction_p.h
+++ b/src/declarative/qml/qmlinstruction_p.h
@@ -183,6 +183,7 @@ public:
struct {
int property;
int owner;
+ int castValue;
} assignValueSource;
struct {
int property;
diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp
index ab64079..c488c13 100644
--- a/src/declarative/qml/qmlmetatype.cpp
+++ b/src/declarative/qml/qmlmetatype.cpp
@@ -120,6 +120,7 @@ public:
QmlAttachedPropertiesFunc m_attachedPropertiesFunc;
const QMetaObject *m_attachedPropertiesType;
int m_parserStatusCast;
+ int m_propertyValueSourceCast;
QmlPrivate::CreateFunc m_extFunc;
const QMetaObject *m_extMetaObject;
int m_index;
@@ -132,8 +133,8 @@ public:
QmlTypePrivate::QmlTypePrivate()
: m_isInterface(false), m_iid(0), m_typeId(0), m_listId(0), m_qmlListId(0),
m_opFunc(0), m_baseMetaObject(0), m_attachedPropertiesFunc(0), m_attachedPropertiesType(0),
- m_parserStatusCast(-1), m_extFunc(0), m_extMetaObject(0), m_index(-1),
- m_customParser(0), m_isSetup(false)
+ m_parserStatusCast(-1), m_propertyValueSourceCast(-1), m_extFunc(0), m_extMetaObject(0),
+ m_index(-1), m_customParser(0), m_isSetup(false)
{
}
@@ -161,7 +162,7 @@ QmlType::QmlType(int type, int listType, int qmlListType,
const QMetaObject *metaObject,
QmlAttachedPropertiesFunc attachedPropertiesFunc,
const QMetaObject *attachedType,
- int parserStatusCast, QmlPrivate::CreateFunc extFunc,
+ int parserStatusCast, int propertyValueSourceCast, QmlPrivate::CreateFunc extFunc,
const QMetaObject *extMetaObject, int index,
QmlCustomParser *customParser)
: d(new QmlTypePrivate)
@@ -178,6 +179,7 @@ QmlType::QmlType(int type, int listType, int qmlListType,
d->m_attachedPropertiesFunc = attachedPropertiesFunc;
d->m_attachedPropertiesType = attachedType;
d->m_parserStatusCast = parserStatusCast;
+ d->m_propertyValueSourceCast = propertyValueSourceCast;
d->m_extFunc = extFunc;
d->m_index = index;
d->m_customParser = customParser;
@@ -397,6 +399,11 @@ int QmlType::parserStatusCast() const
return d->m_parserStatusCast;
}
+int QmlType::propertyValueSourceCast() const
+{
+ return d->m_propertyValueSourceCast;
+}
+
QVariant QmlType::fromObject(QObject *obj) const
{
QVariant rv;
@@ -452,7 +459,7 @@ int QmlMetaType::registerInterface(const QmlPrivate::MetaTypeIds &id,
int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QmlPrivate::Func func,
const char *uri, int version_maj, int version_min_from, int version_min_to, const char *cname,
const QMetaObject *mo, QmlAttachedPropertiesFunc attach, const QMetaObject *attachMo,
- int pStatus, int object, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *parser)
+ int pStatus, int object, int valueSource, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *parser)
{
Q_UNUSED(object);
@@ -476,8 +483,8 @@ int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QmlPrivate::Fun
name.replace('.','/');
QmlType *type = new QmlType(id.typeId, id.listId, id.qmlListId,
- func, name, version_maj, version_min_from, version_min_to, mo, attach, attachMo, pStatus, extFunc,
- extmo, index, parser);
+ func, name, version_maj, version_min_from, version_min_to, mo, attach, attachMo, pStatus,
+ valueSource, extFunc, extmo, index, parser);
data->types.append(type);
data->idToType.insert(type->typeId(), type);
@@ -513,6 +520,17 @@ int QmlMetaType::qmlParserStatusCast(int userType)
return -1;
}
+int QmlMetaType::qmlPropertyValueSourceCast(int userType)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QmlMetaTypeData *data = metaTypeData();
+ QmlType *type = data->idToType.value(userType);
+ if (type && type->typeId() == userType)
+ return type->propertyValueSourceCast();
+ else
+ return -1;
+}
+
QObject *QmlMetaType::toQObject(const QVariant &v)
{
if (!isObject(v.userType()))
diff --git a/src/declarative/qml/qmlmetatype.h b/src/declarative/qml/qmlmetatype.h
index c388b1a..5ed9a5a 100644
--- a/src/declarative/qml/qmlmetatype.h
+++ b/src/declarative/qml/qmlmetatype.h
@@ -47,6 +47,7 @@
#include <QtCore/qbitarray.h>
#include <QtDeclarative/qmlprivate.h>
#include <QtDeclarative/qmlparserstatus.h>
+#include <QtDeclarative/qmlpropertyvaluesource.h>
QT_BEGIN_HEADER
@@ -59,7 +60,7 @@ class QmlCustomParser;
class Q_DECLARATIVE_EXPORT QmlMetaType
{
public:
- static int registerType(const QmlPrivate::MetaTypeIds &, QmlPrivate::Func, const char *, int vmaj, int vmin_from, int vmin_to, const char *qmlName, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int pStatus, int object, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *);
+ static int registerType(const QmlPrivate::MetaTypeIds &, QmlPrivate::Func, const char *, int vmaj, int vmin_from, int vmin_to, const char *qmlName, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int pStatus, int object, int valueSource, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *);
static int registerInterface(const QmlPrivate::MetaTypeIds &, QmlPrivate::Func, const char *);
static bool copy(int type, void *data, const void *copy = 0);
@@ -78,6 +79,7 @@ public:
static QMetaProperty property(QObject *, const char *);
static QObject *toQObject(const QVariant &);
static int qmlParserStatusCast(int);
+ static int qmlPropertyValueSourceCast(int);
static int listType(int);
static bool clear(const QVariant &);
static bool append(const QVariant &, const QVariant &);
@@ -143,13 +145,14 @@ public:
int parserStatusCast() const;
QVariant fromObject(QObject *) const;
const char *interfaceIId() const;
+ int propertyValueSourceCast() const;
int index() const;
private:
friend class QmlMetaType;
friend class QmlTypePrivate;
QmlType(int, int, int, QmlPrivate::Func, const char *, int);
- QmlType(int, int, int, QmlPrivate::Func, const char *, int, int, int, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int, QmlPrivate::CreateFunc, const QMetaObject *, int, QmlCustomParser *);
+ QmlType(int, int, int, QmlPrivate::Func, const char *, int, int, int, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int, int, QmlPrivate::CreateFunc, const QMetaObject *, int, QmlCustomParser *);
~QmlType();
QmlTypePrivate *d;
@@ -170,7 +173,8 @@ int qmlRegisterType(const char *typeName)
QmlPrivate::attachedPropertiesFunc<T>(),
QmlPrivate::attachedPropertiesMetaObject<T>(),
QmlPrivate::StaticCastSelector<T,QmlParserStatus>::cast(),
- QmlPrivate::StaticCastSelector<T,QObject>::cast(),
+ QmlPrivate::StaticCastSelector<T,QObject>::cast(),
+ QmlPrivate::StaticCastSelector<T,QmlPropertyValueSource>::cast(),
0, 0, 0);
}
@@ -191,6 +195,7 @@ int qmlRegisterType(const char *uri, int version_maj, int version_min_from, int
QmlPrivate::attachedPropertiesMetaObject<T>(),
QmlPrivate::StaticCastSelector<T,QmlParserStatus>::cast(),
QmlPrivate::StaticCastSelector<T,QObject>::cast(),
+ QmlPrivate::StaticCastSelector<T,QmlPropertyValueSource>::cast(),
0, 0, 0);
}
@@ -216,7 +221,8 @@ int qmlRegisterExtendedType(const char *typeName)
return QmlMetaType::registerType(ids, QmlPrivate::list_nocreate_op<T>, 0, 0, 0, 0, 0,
&T::staticMetaObject, attached, attachedMo,
QmlPrivate::StaticCastSelector<T,QmlParserStatus>::cast(),
- QmlPrivate::StaticCastSelector<T,QObject>::cast(),
+ QmlPrivate::StaticCastSelector<T,QObject>::cast(),
+ QmlPrivate::StaticCastSelector<T,QmlPropertyValueSource>::cast(),
&QmlPrivate::CreateParent<E>::create, &E::staticMetaObject, 0);
}
@@ -244,7 +250,8 @@ int qmlRegisterExtendedType(const char *uri, int version_maj, int version_min_fr
&T::staticMetaObject,
attached, attachedMo,
QmlPrivate::StaticCastSelector<T,QmlParserStatus>::cast(),
- QmlPrivate::StaticCastSelector<T,QObject>::cast(),
+ QmlPrivate::StaticCastSelector<T,QObject>::cast(),
+ QmlPrivate::StaticCastSelector<T,QmlPropertyValueSource>::cast(),
&QmlPrivate::CreateParent<E>::create,
&E::staticMetaObject, 0);
}
@@ -280,7 +287,8 @@ int qmlRegisterCustomType(const char *uri, int version_maj, int version_min_from
QmlPrivate::attachedPropertiesFunc<T>(),
QmlPrivate::attachedPropertiesMetaObject<T>(),
QmlPrivate::StaticCastSelector<T,QmlParserStatus>::cast(),
- QmlPrivate::StaticCastSelector<T,QObject>::cast(),
+ QmlPrivate::StaticCastSelector<T,QObject>::cast(),
+ QmlPrivate::StaticCastSelector<T,QmlPropertyValueSource>::cast(),
0, 0, parser);
}
diff --git a/src/declarative/qml/qmlpropertyvaluesource.cpp b/src/declarative/qml/qmlpropertyvaluesource.cpp
index c6ff596..429080b 100644
--- a/src/declarative/qml/qmlpropertyvaluesource.cpp
+++ b/src/declarative/qml/qmlpropertyvaluesource.cpp
@@ -48,34 +48,18 @@ QT_BEGIN_NAMESPACE
\class QmlPropertyValueSource
\brief The QmlPropertyValueSource class is inherited by property value sources such as animations and bindings.
*/
-QML_DEFINE_NOCREATE_TYPE(QmlPropertyValueSource)
/*!
- Constructs a QmlPropertyValueSource with parent \a parent.
+ Constructs a QmlPropertyValueSource.
*/
-QmlPropertyValueSource::QmlPropertyValueSource(QObject *parent)
- : QObject(parent)
-
-{
-}
-
-/*!
- \internal
- */
-QmlPropertyValueSource::QmlPropertyValueSource(QObjectPrivate &dd, QObject *parent)
- : QObject(dd, parent)
+QmlPropertyValueSource::QmlPropertyValueSource()
{
}
/*!
+ \fn void QmlPropertyValueSource::setTarget(const QmlMetaProperty &property)
Set the target \a property for the value source. This method will
be called by the QML engine when assigning a value source.
-
- The default implementation does nothing.
*/
-void QmlPropertyValueSource::setTarget(const QmlMetaProperty &property)
-{
- Q_UNUSED(property);
-}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlpropertyvaluesource.h b/src/declarative/qml/qmlpropertyvaluesource.h
index 4e5f1c5..ee4ea2c 100644
--- a/src/declarative/qml/qmlpropertyvaluesource.h
+++ b/src/declarative/qml/qmlpropertyvaluesource.h
@@ -42,9 +42,7 @@
#ifndef QMLPROPERTYVALUESOURCE_H
#define QMLPROPERTYVALUESOURCE_H
-#include <QtDeclarative/qfxglobal.h>
-#include <QtDeclarative/qml.h>
-#include <QtCore/QObject>
+#include <QtCore/qobject.h>
QT_BEGIN_HEADER
@@ -52,28 +50,17 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QObjectPrivate;
class QmlMetaProperty;
-class Q_DECLARATIVE_EXPORT QmlPropertyValueSource : public QObject
+class Q_DECLARATIVE_EXPORT QmlPropertyValueSource
{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QObject)
-
public:
- QmlPropertyValueSource(QObject *parent);
- virtual void setTarget(const QmlMetaProperty &);
-
-protected:
- QmlPropertyValueSource(QObjectPrivate &dd, QObject *parent);
-
-private:
- Q_DISABLE_COPY(QmlPropertyValueSource)
+ QmlPropertyValueSource();
+ virtual void setTarget(const QmlMetaProperty &) = 0;
};
+Q_DECLARE_INTERFACE(QmlPropertyValueSource, "com.trolltech.qml.QmlPropertyValueSource")
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QmlPropertyValueSource)
-
QT_END_HEADER
#endif // QMLPROPERTYVALUESOURCE_H
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index 7455eb4..930e6e4 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -591,13 +591,12 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledData
case QmlInstruction::StoreValueSource:
{
- QmlPropertyValueSource *vs =
- static_cast<QmlPropertyValueSource *>(stack.pop());
- QObject *target =
- stack.at(stack.count() - 1 - instr.assignValueSource.owner);
+ QObject *obj = stack.pop();
+ QmlPropertyValueSource *vs = reinterpret_cast<QmlPropertyValueSource *>(reinterpret_cast<char *>(obj) + instr.assignValueSource.castValue);
+ QObject *target = stack.at(stack.count() - 1 - instr.assignValueSource.owner);
QmlMetaProperty prop;
prop.restore(instr.assignValueSource.property, target, ctxt);
- vs->setParent(target);
+ obj->setParent(target);
vs->setTarget(prop);
}
break;