summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-02-03 05:25:14 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-02-03 05:25:14 (GMT)
commit135e8cd5be1b15a265f11f9e5dc99091d64dc090 (patch)
tree2eaaf42f8f01b71e28aab2c54157125591935989 /src/declarative/qml
parent28093fa09de04d0633c261a91fd3746c107963fc (diff)
parent76f8d4eba12cd806270c145f908c96d4cd1c72cf (diff)
downloadQt-135e8cd5be1b15a265f11f9e5dc99091d64dc090.zip
Qt-135e8cd5be1b15a265f11f9e5dc99091d64dc090.tar.gz
Qt-135e8cd5be1b15a265f11f9e5dc99091d64dc090.tar.bz2
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qmlcompiler.cpp51
1 files changed, 49 insertions, 2 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index c6a5d82..a7ae649 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -680,6 +680,13 @@ void QmlCompiler::compileTree(Object *tree)
QmlEnginePrivate::get(engine)->registerCompositeType(output);
}
+static bool ValuePtrLessThan(const Value *t1, const Value *t2)
+{
+ return t1->location.start.line < t2->location.start.line ||
+ (t1->location.start.line == t2->location.start.line &&
+ t1->location.start.column < t2->location.start.column);
+}
+
bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
{
componentStat.objects++;
@@ -739,9 +746,46 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
}
}
+ // Merge
+ Property *defaultProperty = 0;
+ Property *skipProperty = 0;
+ if (obj->defaultProperty) {
+ const QMetaObject *metaObject = obj->metaObject();
+ Q_ASSERT(metaObject);
+ QMetaProperty p = QmlMetaType::defaultProperty(metaObject);
+ if (p.name()) {
+ Property *explicitProperty = obj->getProperty(p.name(), false);
+ if (explicitProperty && !explicitProperty->value) {
+ skipProperty = explicitProperty;
+
+ defaultProperty = new Property;
+ defaultProperty->parent = obj;
+ defaultProperty->isDefault = true;
+ defaultProperty->location = obj->defaultProperty->location;
+ defaultProperty->listValueRange = obj->defaultProperty->listValueRange;
+ defaultProperty->listCommaPositions = obj->defaultProperty->listCommaPositions;
+
+ defaultProperty->values = obj->defaultProperty->values;
+ defaultProperty->values += explicitProperty->values;
+ foreach(Value *value, defaultProperty->values)
+ value->addref();
+ qSort(defaultProperty->values.begin(), defaultProperty->values.end(), ValuePtrLessThan);
+
+ } else {
+ defaultProperty = obj->defaultProperty;
+ defaultProperty->addref();
+ }
+ } else {
+ defaultProperty = obj->defaultProperty;
+ defaultProperty->addref();
+ }
+ }
+
// Build all explicit properties specified
foreach(Property *prop, obj->properties) {
+ if (prop == skipProperty)
+ continue;
if (prop->name == "id")
continue;
@@ -771,8 +815,8 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
}
// Build the default property
- if (obj->defaultProperty) {
- Property *prop = obj->defaultProperty;
+ if (defaultProperty) {
+ Property *prop = defaultProperty;
bool canDefer = false;
if (isCustomParser) {
@@ -794,6 +838,9 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
prop->isDeferred = true;
}
+ if (defaultProperty)
+ defaultProperty->release();
+
// Compile custom parser parts
if (isCustomParser && !customProps.isEmpty()) {
QmlCustomParser *cp = output->types.at(obj->type).type->customParser();