summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-08-03 05:44:21 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-08-03 05:44:21 (GMT)
commit6d6995e65ba394c842a1bf37c0d5c083aab221a9 (patch)
tree91e1a96af1e4b913b140a64243324f03c07d377a
parent3c0ea527433dde04ee69c94a3f95f2d2d6b6a02d (diff)
parent9440ad04903f2e9c2d3019acc774084fb9a26c79 (diff)
downloadQt-6d6995e65ba394c842a1bf37c0d5c083aab221a9.zip
Qt-6d6995e65ba394c842a1bf37c0d5c083aab221a9.tar.gz
Qt-6d6995e65ba394c842a1bf37c0d5c083aab221a9.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--demos/declarative/calculator/CalcButton.qml57
-rw-r--r--demos/declarative/calculator/calculator.qml13
-rw-r--r--demos/declarative/calculator/pics/button-pressed.pngbin644 -> 0 bytes
-rw-r--r--demos/declarative/calculator/pics/button-pressed.sci5
-rw-r--r--demos/declarative/calculator/pics/button.pngbin635 -> 0 bytes
-rw-r--r--demos/declarative/calculator/pics/button.sci5
-rw-r--r--demos/declarative/calculator/pics/clear.pngbin611 -> 0 bytes
-rw-r--r--demos/declarative/flickr/flickr.qml11
-rw-r--r--src/declarative/extra/qmlxmllistmodel.h2
-rw-r--r--src/declarative/qml/qmlcompiler.cpp231
-rw-r--r--src/declarative/qml/qmlengine.cpp109
-rw-r--r--src/declarative/qml/qmlengine_p.h2
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp156
-rw-r--r--src/declarative/qml/qmlmetaproperty.h2
-rw-r--r--src/declarative/qml/qmlmetaproperty_p.h16
-rw-r--r--src/declarative/qml/qmlmetatype.cpp56
-rw-r--r--src/declarative/qml/qmlvaluetype.cpp4
-rw-r--r--src/declarative/util/qmlfollow.cpp2
-rw-r--r--src/declarative/util/qmlpalette.cpp30
-rw-r--r--src/declarative/util/qmlpalette.h12
-rw-r--r--src/declarative/util/qmlstate.cpp19
-rw-r--r--src/declarative/util/qmlstateoperations.cpp10
-rw-r--r--tests/benchmarks/declarative/qmlcomponent/myqmlobject.txt2
-rw-r--r--tests/benchmarks/declarative/qmlcomponent/myqmlobject_binding.txt2
-rw-r--r--tests/benchmarks/declarative/qmlcomponent/object.txt2
-rw-r--r--tests/benchmarks/declarative/qmlcomponent/synthesized_properties.2.txt2
-rw-r--r--tests/benchmarks/declarative/qmlcomponent/synthesized_properties.txt2
-rw-r--r--tests/benchmarks/declarative/qmlcomponent/testtypes.cpp2
-rw-r--r--tests/benchmarks/declarative/qmlmetaproperty/object.txt3
-rw-r--r--tests/benchmarks/declarative/qmlmetaproperty/qmlmetaproperty.pro7
-rw-r--r--tests/benchmarks/declarative/qmlmetaproperty/synthesized_object.txt6
-rw-r--r--tests/benchmarks/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp79
32 files changed, 473 insertions, 376 deletions
diff --git a/demos/declarative/calculator/CalcButton.qml b/demos/declarative/calculator/CalcButton.qml
index 5eb7fe1..ebb1967 100644
--- a/demos/declarative/calculator/CalcButton.qml
+++ b/demos/declarative/calculator/CalcButton.qml
@@ -1,62 +1,41 @@
import Qt 4.6
-Item {
+Rect {
property string operation
property bool toggable : false
property bool toggled : false
+ signal clicked
id: Button; width: 50; height: 30
-
- Script {
- function buttonClicked(operation) {
- if (Button.toggable == true) {
- if (Button.toggled == true) {
- Button.toggled = false;
- Button.state = 'Toggled';
- } else {
- Button.toggled = true;
- Button.state = '';
- }
- }
- else
- doOp(operation);
- }
- }
-
- Image {
- id: Image
- source: "pics/button.sci"
- width: Button.width; height: Button.height
+ border.color: Palette.mid; radius: 6
+ gradient: Gradient {
+ GradientStop { id: G1; position: 0.0; color: Palette.lighter(Palette.button) }
+ GradientStop { id: G2; position: 1.0; color: Palette.button }
}
- Image {
- id: ImagePressed
- source: "pics/button-pressed.sci"
- width: Button.width; height: Button.height
- opacity: 0
- }
-
- Text {
- anchors.centerIn: Image
- text: Button.operation
- color: "white"
- font.bold: true
- }
+ Text { anchors.centerIn: parent; text: operation; color: Palette.buttonText }
MouseRegion {
id: MouseRegion
- anchors.fill: Button
- onClicked: { buttonClicked(Button.operation) }
+ anchors.fill: parent
+ onClicked: {
+ doOp(operation);
+ Button.clicked();
+ if (!Button.toggable) return;
+ Button.toggled ? Button.toggled = false : Button.toggled = true
+ }
}
states: [
State {
name: "Pressed"; when: MouseRegion.pressed == true
- SetProperties { target: ImagePressed; opacity: 1 }
+ SetProperties { target: G1; color: Palette.dark }
+ SetProperties { target: G2; color: Palette.button }
},
State {
name: "Toggled"; when: Button.toggled == true
- SetProperties { target: ImagePressed; opacity: 1 }
+ SetProperties { target: G1; color: Palette.dark }
+ SetProperties { target: G2; color: Palette.button }
}
]
}
diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml
index 576fea9..a4e16e4 100644
--- a/demos/declarative/calculator/calculator.qml
+++ b/demos/declarative/calculator/calculator.qml
@@ -2,22 +2,23 @@ import Qt 4.6
Rect {
id: MainWindow;
- width: 320; height: 270; color: "black"
+ width: 320; height: 270; color: Palette.window
+ Palette { id: Palette }
Script { source: "calculator.js" }
VerticalLayout {
- spacing: 2; margin: 2
+ x: 2; spacing: 10; margin: 2
Rect {
id: Container
- width: 316; height: 60; z: 2
- border.color: "white"; color: "#343434"
+ width: 316; height: 50; z: 2
+ border.color: Palette.dark; color: Palette.base
Text {
id: CurNum
font.bold: true; font.size: 16
- color: "white"
+ color: Palette.text
anchors.right: Container.right
anchors.rightMargin: 5
anchors.verticalCenter: Container.verticalCenter
@@ -25,7 +26,7 @@ Rect {
Text {
id: CurrentOperation
- color: "white"
+ color: Palette.text
font.bold: true; font.size: 16
anchors.left: Container.left
anchors.leftMargin: 5
diff --git a/demos/declarative/calculator/pics/button-pressed.png b/demos/declarative/calculator/pics/button-pressed.png
deleted file mode 100644
index 1a24cee..0000000
--- a/demos/declarative/calculator/pics/button-pressed.png
+++ /dev/null
Binary files differ
diff --git a/demos/declarative/calculator/pics/button-pressed.sci b/demos/declarative/calculator/pics/button-pressed.sci
deleted file mode 100644
index f3bc860..0000000
--- a/demos/declarative/calculator/pics/button-pressed.sci
+++ /dev/null
@@ -1,5 +0,0 @@
-gridLeft: 5
-gridTop: 5
-gridBottom: 5
-gridRight: 5
-imageFile: button-pressed.png
diff --git a/demos/declarative/calculator/pics/button.png b/demos/declarative/calculator/pics/button.png
deleted file mode 100644
index 88c8bf8..0000000
--- a/demos/declarative/calculator/pics/button.png
+++ /dev/null
Binary files differ
diff --git a/demos/declarative/calculator/pics/button.sci b/demos/declarative/calculator/pics/button.sci
deleted file mode 100644
index b1c7929..0000000
--- a/demos/declarative/calculator/pics/button.sci
+++ /dev/null
@@ -1,5 +0,0 @@
-gridLeft: 5
-gridTop: 5
-gridBottom: 5
-gridRight: 5
-imageFile: button.png
diff --git a/demos/declarative/calculator/pics/clear.png b/demos/declarative/calculator/pics/clear.png
deleted file mode 100644
index fb07a27c..0000000
--- a/demos/declarative/calculator/pics/clear.png
+++ /dev/null
Binary files differ
diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml
index 57fc349..c0a1a87 100644
--- a/demos/declarative/flickr/flickr.qml
+++ b/demos/declarative/flickr/flickr.qml
@@ -33,9 +33,10 @@ Item {
id: Wrapper; width: 85; height: 85
scale: Wrapper.PathView.scale; z: Wrapper.PathView.z
- transform: [
- Rotation3D { id: Rotation; origin.x: 30; axis.x: 30; axis.y: 60; angle: Wrapper.PathView.angle }
- ]
+ transform: Rotation3D {
+ id: Rotation; origin.x: Wrapper.width/2; origin.y: Wrapper.height/2
+ axis.y: 1; angle: Wrapper.PathView.angle
+ }
Connection {
sender: ImageDetails; signal: "closed()"
@@ -112,14 +113,14 @@ Item {
}
}
]
-
+
}
}
]
Item {
id: Background
-
+
anchors.fill: parent
Image { source: "content/pics/background.png"; anchors.fill: parent }
diff --git a/src/declarative/extra/qmlxmllistmodel.h b/src/declarative/extra/qmlxmllistmodel.h
index 3b6ffb4..18d33fb 100644
--- a/src/declarative/extra/qmlxmllistmodel.h
+++ b/src/declarative/extra/qmlxmllistmodel.h
@@ -121,7 +121,7 @@ public:
QString namespaceDeclarations() const;
void setNamespaceDeclarations(const QString&);
- enum Status { Idle, Loading, Error };
+ enum Status { Idle, Loading, Error }; // ### should include Null for consistency?
Status status() const;
qreal progress() const;
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 59cf15d..091b7bb 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -89,7 +89,7 @@ QmlCompiler::QmlCompiler()
*/
bool QmlCompiler::isError() const
{
- return !exceptions.isEmpty();
+ return !exceptions.isEmpty();
}
/*!
@@ -113,7 +113,7 @@ bool QmlCompiler::isValidId(const QString &val)
return false;
QChar u(QLatin1Char('_'));
- for (int ii = 0; ii < val.count(); ++ii)
+ 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())) )
@@ -140,12 +140,12 @@ bool QmlCompiler::isAttachedPropertyName(const QByteArray &name)
*/
bool QmlCompiler::isSignalPropertyName(const QByteArray &name)
{
- return name.length() >= 3 && name.startsWith("on") &&
+ return name.length() >= 3 && name.startsWith("on") &&
'A' <= name.at(2) && 'Z' >= name.at(2);
}
/*!
- Inserts an error into the QmlCompiler error list, and returns false
+ Inserts an error into the QmlCompiler error list, and returns false
(failure).
\a token is used to source the error line and column, and \a desc is the
@@ -169,7 +169,7 @@ bool QmlCompiler::isSignalPropertyName(const QByteArray &name)
error.setDescription(exceptionDescription.trimmed()); \
exceptions << error; \
return false; \
- }
+ }
/*!
Returns false if \a is false, otherwise does nothing.
@@ -186,13 +186,13 @@ bool QmlCompiler::isSignalPropertyName(const QByteArray &name)
This test corresponds to action taken by genLiteralAssignment(). Any change
made here, must have a corresponding action in genLiteralAssigment().
*/
-bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop,
+bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop,
QmlParser::Value *v)
{
QString string = v->value.asScript();
if (!prop.isWritable())
- COMPILE_EXCEPTION(v, "Invalid property assignment: read-only property");
+ COMPILE_EXCEPTION(v, "Invalid property assignment: read-only property");
if (prop.isEnumType()) {
int value;
@@ -300,9 +300,9 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop,
int t = prop.type();
if (t == QVariant::UserType)
t = prop.userType();
- QmlMetaType::StringConverter converter =
+ QmlMetaType::StringConverter converter =
QmlMetaType::customStringConverter(t);
- if (!converter)
+ if (!converter)
COMPILE_EXCEPTION(v, "Invalid property assignment: unknown type" << prop.type());
}
break;
@@ -408,7 +408,7 @@ void QmlCompiler::genLiteralAssignment(const QMetaProperty &prop,
case QVariant::Time:
{
QTime time = QTime::fromString(string, Qt::ISODate);
- int data[] = { time.hour(), time.minute(),
+ int data[] = { time.hour(), time.minute(),
time.second(), time.msec() };
int index = output->indexForInt(data, 4);
instr.type = QmlInstruction::StoreTime;
@@ -434,7 +434,7 @@ void QmlCompiler::genLiteralAssignment(const QMetaProperty &prop,
case QVariant::PointF:
{
bool ok;
- QPointF point =
+ QPointF point =
QmlStringConverters::pointFFromString(string, &ok);
float data[] = { point.x(), point.y() };
int index = output->indexForFloat(data, 2);
@@ -466,7 +466,7 @@ void QmlCompiler::genLiteralAssignment(const QMetaProperty &prop,
{
bool ok;
QRectF rect = QmlStringConverters::rectFFromString(string, &ok);
- float data[] = { rect.x(), rect.y(),
+ float data[] = { rect.x(), rect.y(),
rect.width(), rect.height() };
int index = output->indexForFloat(data, 4);
if (type == QVariant::RectF)
@@ -523,14 +523,14 @@ void QmlCompiler::reset(QmlCompiledData *data)
Compile \a unit, and store the output in \a out. \a engine is the QmlEngine
with which the QmlCompiledData will be associated.
- Returns true on success, false on failure. On failure, the compile errors
+ Returns true on success, false on failure. On failure, the compile errors
are available from errors().
- If the environment variant QML_COMPILER_DUMP is set
+ If the environment variant QML_COMPILER_DUMP is set
(eg. QML_COMPILER_DUMP=1) the compiled instructions will be dumped to stderr
on a successful compiler.
*/
-bool QmlCompiler::compile(QmlEngine *engine,
+bool QmlCompiler::compile(QmlEngine *engine,
QmlCompositeTypeData *unit,
QmlCompiledData *out)
{
@@ -555,8 +555,8 @@ bool QmlCompiler::compile(QmlEngine *engine,
if (ref.component->isError()) {
QmlError error;
- error.setUrl(output->url);
- error.setDescription(QLatin1String("Unable to create type ") +
+ error.setUrl(output->url);
+ error.setDescription(QLatin1String("Unable to create type ") +
unit->data.types().at(ii));
exceptions << error;
exceptions << ref.component->errors();
@@ -565,7 +565,7 @@ bool QmlCompiler::compile(QmlEngine *engine,
}
ref.ref = tref.unit;
ref.ref->addref();
- }
+ }
ref.className = unit->data.types().at(ii).toLatin1();
out->types << ref;
}
@@ -620,13 +620,13 @@ void QmlCompiler::compileTree(Object *tree)
}
bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
-{
+{
Q_ASSERT (obj->type != -1);
- const QmlCompiledData::TypeReference &tr =
+ const QmlCompiledData::TypeReference &tr =
output->types.at(obj->type);
obj->metatype = tr.metaObject();
- if (tr.component)
+ if (tr.component)
obj->url = tr.component->url();
if (tr.type)
obj->typeName = tr.type->qmlTypeName();
@@ -652,10 +652,10 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
if (obj->parserStatusCast != -1)
compileState.parserStatusCount++;
- // Check if this is a custom parser type. Custom parser types allow
+ // Check if this is a custom parser type. Custom parser types allow
// assignments to non-existant properties. These assignments are then
// compiled by the type.
- bool isCustomParser = output->types.at(obj->type).type &&
+ bool isCustomParser = output->types.at(obj->type).type &&
output->types.at(obj->type).type->customParser() != 0;
QList<QmlCustomParserProperty> customProps;
@@ -663,7 +663,7 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
QStringList deferredList = deferredProperties(obj);
// Must do id property first. This is to ensure that the id given to any
- // id reference created matches the order in which the objects are
+ // id reference created matches the order in which the objects are
// instantiated
foreach(Property *prop, obj->properties) {
if (prop->name == "id") {
@@ -697,8 +697,8 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
}
}
- if (canDefer && !deferredList.isEmpty() &&
- deferredList.contains(prop->name))
+ if (canDefer && !deferredList.isEmpty() &&
+ deferredList.contains(prop->name))
prop->isDeferred = true;
}
@@ -722,8 +722,8 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
canDefer = ids == compileState.ids.count();
}
- if (canDefer && !deferredList.isEmpty() &&
- deferredList.contains(prop->name))
+ if (canDefer && !deferredList.isEmpty() &&
+ deferredList.contains(prop->name))
prop->isDeferred = true;
}
@@ -808,12 +808,12 @@ void QmlCompiler::genObjectBody(QmlParser::Object *obj)
output->bytecode << defer;
foreach(Property *prop, obj->valueProperties) {
- if (!prop->isDeferred)
+ if (!prop->isDeferred)
continue;
genValueProperty(prop, obj);
}
- output->bytecode[deferIdx].defer.deferCount =
+ output->bytecode[deferIdx].defer.deferCount =
output->bytecode.count() - deferIdx - 1;
}
@@ -828,7 +828,7 @@ void QmlCompiler::genObjectBody(QmlParser::Object *obj)
QmlInstruction assign;
assign.type = QmlInstruction::AssignSignalObject;
assign.line = v->location.start.line;
- assign.assignSignalObject.signal =
+ assign.assignSignalObject.signal =
output->indexForByteArray(prop->name);
output->bytecode << assign;
@@ -838,7 +838,7 @@ void QmlCompiler::genObjectBody(QmlParser::Object *obj)
store.type = QmlInstruction::StoreSignal;
store.line = v->location.start.line;
store.storeSignal.signalIndex = prop->index;
- store.storeSignal.value =
+ store.storeSignal.value =
output->indexForString(v->value.asScript().trimmed());
output->bytecode << store;
@@ -908,7 +908,7 @@ void QmlCompiler::genComponent(QmlParser::Object *obj)
create.line = root->location.start.line;
create.createComponent.endLine = root->location.end.line;
output->bytecode << create;
- int count = output->bytecode.count();
+ int count = output->bytecode.count();
ComponentCompileState oldCompileState = compileState;
compileState = componentState(root);
@@ -941,7 +941,7 @@ void QmlCompiler::genComponent(QmlParser::Object *obj)
}
}
-bool QmlCompiler::buildComponent(QmlParser::Object *obj,
+bool QmlCompiler::buildComponent(QmlParser::Object *obj,
const BindingContext &ctxt)
{
// The special "Component" element can only have the id property and a
@@ -953,7 +953,7 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj,
(obj->properties.count() == 1 && obj->properties.begin().key() != "id"))
COMPILE_EXCEPTION(obj, "Invalid component specification");
- if (obj->properties.count())
+ if (obj->properties.count())
idProp = *obj->properties.begin();
if (idProp && (idProp->value || idProp->values.count() > 1 || !isValidId(idProp->values.first()->primitive())))
COMPILE_EXCEPTION(obj, "Invalid component id specification");
@@ -969,15 +969,15 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj,
}
// Check the Component tree is well formed
- if (obj->defaultProperty &&
+ if (obj->defaultProperty &&
(obj->defaultProperty->value || obj->defaultProperty->values.count() > 1 ||
(obj->defaultProperty->values.count() == 1 && !obj->defaultProperty->values.first()->object)))
COMPILE_EXCEPTION(obj, "Invalid component body specification");
Object *root = 0;
- if (obj->defaultProperty && obj->defaultProperty->values.count())
+ if (obj->defaultProperty && obj->defaultProperty->values.count())
root = obj->defaultProperty->values.first()->object;
-
+
if (!root)
COMPILE_EXCEPTION(obj, "Cannot create empty component specification");
@@ -987,14 +987,14 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj,
return true;
}
-bool QmlCompiler::buildComponentFromRoot(QmlParser::Object *obj,
+bool QmlCompiler::buildComponentFromRoot(QmlParser::Object *obj,
const BindingContext &ctxt)
{
ComponentCompileState oldComponentCompileState = compileState;
compileState = ComponentCompileState();
compileState.root = obj;
- if (obj)
+ if (obj)
COMPILE_CHECK(buildObject(obj, ctxt));
COMPILE_CHECK(completeComponentBuild());
@@ -1005,16 +1005,16 @@ bool QmlCompiler::buildComponentFromRoot(QmlParser::Object *obj,
}
-// Build a sub-object. A sub-object is one that was not created directly by
+// Build a sub-object. A sub-object is one that was not created directly by
// QML - such as a grouped property object, or an attached object. Sub-object's
// can't have an id, involve a custom parser, have attached properties etc.
bool QmlCompiler::buildSubObject(Object *obj, const BindingContext &ctxt)
{
Q_ASSERT(obj->metatype);
- Q_ASSERT(ctxt.isSubContext()); // sub-objects must always be in a binding
+ Q_ASSERT(ctxt.isSubContext()); // sub-objects must always be in a binding
// sub-context
- if (obj->defaultProperty)
+ if (obj->defaultProperty)
COMPILE_CHECK(buildProperty(obj->defaultProperty, obj, ctxt));
foreach(Property *prop, obj->properties) {
@@ -1051,7 +1051,7 @@ int QmlCompiler::findSignalByName(const QMetaObject *mo, const QByteArray &name)
int idx = methodName.indexOf('(');
methodName = methodName.left(idx);
- if (methodName == name)
+ if (methodName == name)
return ii;
}
return -1;
@@ -1094,7 +1094,7 @@ bool QmlCompiler::buildSignal(QmlParser::Property *prop, QmlParser::Object *obj,
prop->values.at(0)->type = Value::SignalExpression;
}
}
-
+
return true;
}
@@ -1102,7 +1102,7 @@ bool QmlCompiler::buildSignal(QmlParser::Property *prop, QmlParser::Object *obj,
/*!
Returns true if (value) property \a prop exists on obj, false otherwise.
*/
-bool QmlCompiler::doesPropertyExist(QmlParser::Property *prop,
+bool QmlCompiler::doesPropertyExist(QmlParser::Property *prop,
QmlParser::Object *obj)
{
if(isAttachedPropertyName(prop->name) || prop->name == "id")
@@ -1118,12 +1118,12 @@ bool QmlCompiler::doesPropertyExist(QmlParser::Property *prop,
return idx != -1;
}
}
-
+
return false;
}
-bool QmlCompiler::buildProperty(QmlParser::Property *prop,
- QmlParser::Object *obj,
+bool QmlCompiler::buildProperty(QmlParser::Property *prop,
+ QmlParser::Object *obj,
const BindingContext &ctxt)
{
if (prop->isEmpty())
@@ -1172,7 +1172,7 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop,
}
}
- // We can't error here as the "id" property does not require a
+ // We can't error here as the "id" property does not require a
// successful index resolution
if (p.name()) {
int t = p.type();
@@ -1187,11 +1187,11 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop,
if (!prop->isDefault && prop->name == "id" && !ctxt.isSubContext()) {
// The magic "id" behaviour doesn't apply when "id" is resolved as a
- // default property or to sub-objects (which are always in binding
+ // default property or to sub-objects (which are always in binding
// sub-contexts)
COMPILE_CHECK(buildIdProperty(prop, obj));
- if (prop->type == QVariant::String &&
- prop->values.at(0)->value.isString())
+ if (prop->type == QVariant::String &&
+ prop->values.at(0)->value.isString())
COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt));
} else if (isAttachedPropertyName(prop->name)) {
@@ -1210,7 +1210,7 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop,
COMPILE_CHECK(buildGroupedProperty(prop, obj, ctxt));
- } else if (QmlMetaType::isQmlList(prop->type) ||
+ } else if (QmlMetaType::isQmlList(prop->type) ||
QmlMetaType::isList(prop->type)) {
COMPILE_CHECK(buildListProperty(prop, obj, ctxt));
@@ -1224,7 +1224,7 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop,
return true;
}
-void QmlCompiler::genValueProperty(QmlParser::Property *prop,
+void QmlCompiler::genValueProperty(QmlParser::Property *prop,
QmlParser::Object *obj)
{
if (QmlMetaType::isQmlList(prop->type) || QmlMetaType::isList(prop->type)) {
@@ -1234,7 +1234,7 @@ void QmlCompiler::genValueProperty(QmlParser::Property *prop,
}
}
-void QmlCompiler::genListProperty(QmlParser::Property *prop,
+void QmlCompiler::genListProperty(QmlParser::Property *prop,
QmlParser::Object *obj)
{
QmlInstruction::Type fetchType;
@@ -1291,7 +1291,7 @@ void QmlCompiler::genListProperty(QmlParser::Property *prop,
output->bytecode << pop;
}
-void QmlCompiler::genPropertyAssignment(QmlParser::Property *prop,
+void QmlCompiler::genPropertyAssignment(QmlParser::Property *prop,
QmlParser::Object *obj,
QmlParser::Property *valueTypeProperty)
{
@@ -1326,7 +1326,7 @@ void QmlCompiler::genPropertyAssignment(QmlParser::Property *prop,
store.storeObject.propertyIndex = prop->index;
output->bytecode << store;
- }
+ }
} else if (v->type == Value::ValueSource) {
genObject(v->object);
@@ -1338,7 +1338,7 @@ void QmlCompiler::genPropertyAssignment(QmlParser::Property *prop,
store.assignValueSource.property = QmlMetaPropertyPrivate::saveValueType(valueTypeProperty->index, prop->index);
store.assignValueSource.owner = 1;
} else {
- store.assignValueSource.property =
+ store.assignValueSource.property =
QmlMetaPropertyPrivate::saveProperty(prop->index);
store.assignValueSource.owner = 0;
}
@@ -1353,12 +1353,12 @@ void QmlCompiler::genPropertyAssignment(QmlParser::Property *prop,
QMetaProperty mp = obj->metaObject()->property(prop->index);
genLiteralAssignment(mp, v);
- }
+ }
}
}
-bool QmlCompiler::buildIdProperty(QmlParser::Property *prop,
+bool QmlCompiler::buildIdProperty(QmlParser::Property *prop,
QmlParser::Object *obj)
{
if (prop->value ||
@@ -1404,7 +1404,7 @@ void QmlCompiler::saveComponentState()
savedCompileStates.insert(compileState.root, compileState);
}
-QmlCompiler::ComponentCompileState
+QmlCompiler::ComponentCompileState
QmlCompiler::componentState(QmlParser::Object *obj)
{
Q_ASSERT(savedCompileStates.contains(obj));
@@ -1416,7 +1416,7 @@ QmlCompiler::componentState(QmlParser::Object *obj)
// GridView.row: 10
// }
// GridView is an attached property object.
-bool QmlCompiler::buildAttachedProperty(QmlParser::Property *prop,
+bool QmlCompiler::buildAttachedProperty(QmlParser::Property *prop,
QmlParser::Object *obj,
const BindingContext &ctxt)
{
@@ -1447,10 +1447,10 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop,
Q_ASSERT(prop->index != -1);
if (prop->type < QVariant::UserType) {
- QmlEnginePrivate *ep =
+ QmlEnginePrivate *ep =
static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine));
if (ep->valueTypes[prop->type]) {
- COMPILE_CHECK(buildValueTypeProperty(ep->valueTypes[prop->type],
+ COMPILE_CHECK(buildValueTypeProperty(ep->valueTypes[prop->type],
prop->value, ctxt.incr()));
obj->addValueTypeProperty(prop);
} else {
@@ -1461,7 +1461,7 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop,
// Load the nested property's meta type
prop->value->metatype = QmlMetaType::metaObjectForType(prop->type);
if (!prop->value->metatype)
- COMPILE_EXCEPTION(prop, "Cannot nest non-QObject property" <<
+ COMPILE_EXCEPTION(prop, "Cannot nest non-QObject property" <<
prop->name);
obj->addGroupedProperty(prop);
@@ -1472,7 +1472,7 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop,
return true;
}
-bool QmlCompiler::buildValueTypeProperty(QObject *type,
+bool QmlCompiler::buildValueTypeProperty(QObject *type,
QmlParser::Object *obj,
const BindingContext &ctxt)
{
@@ -1494,11 +1494,11 @@ bool QmlCompiler::buildValueTypeProperty(QObject *type,
Value *value = prop->values.at(0);
if (value->object) {
- const QMetaObject *c =
+ const QMetaObject *c =
output->types.at(value->object->type).metaObject();
- bool isPropertyValue = false;
+ bool isPropertyValue = false;
while (c && !isPropertyValue) {
- isPropertyValue =
+ isPropertyValue =
(c == &QmlPropertyValueSource::staticMetaObject);
c = c->superClass();
}
@@ -1539,7 +1539,7 @@ bool QmlCompiler::buildListProperty(QmlParser::Property *prop,
QmlParser::Object *obj,
const BindingContext &ctxt)
{
- Q_ASSERT(QmlMetaType::isList(prop->type) ||
+ Q_ASSERT(QmlMetaType::isList(prop->type) ||
QmlMetaType::isQmlList(prop->type));
int t = prop->type;
@@ -1586,7 +1586,7 @@ bool QmlCompiler::buildListProperty(QmlParser::Property *prop,
if (!canCoerce(listType, v->object)) {
COMPILE_EXCEPTION(v, "Cannot assign object to list");
}
- }
+ }
} else if (v->value.isScript()) {
if (assignedBinding)
@@ -1642,7 +1642,7 @@ bool QmlCompiler::buildPropertyAssignment(QmlParser::Property *prop,
return true;
}
-// Compile assigning a single object instance to a regular property
+// Compile assigning a single object instance to a regular property
bool QmlCompiler::buildPropertyObjectAssignment(QmlParser::Property *prop,
QmlParser::Object *obj,
QmlParser::Value *v,
@@ -1665,21 +1665,21 @@ bool QmlCompiler::buildPropertyObjectAssignment(QmlParser::Property *prop,
v->type = Value::CreatedObject;
} else {
- // Normally buildObject() will set this up, but we need the static
+ // Normally buildObject() will set this up, but we need the static
// meta object earlier to test for assignability. It doesn't matter
// that there may still be outstanding synthesized meta object changes
// on this type, as they are not relevant for assignability testing
v->object->metatype = output->types.at(v->object->type).metaObject();
Q_ASSERT(v->object->metaObject());
- // We want to raw metaObject here as the raw metaobject is the
- // actual property type before we applied any extensions that might
+ // 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 =
+ const QMetaObject *propertyMetaObject =
QmlMetaType::rawMetaObjectForType(prop->type);
-
+
// Will be true if the assigned type inherits QmlPropertyValueSource
- bool isPropertyValue = false;
+ bool isPropertyValue = false;
// Will be true if the assgned type inherits propertyMetaObject
bool isAssignable = false;
// Determine isPropertyValue and isAssignable values
@@ -1729,7 +1729,7 @@ bool QmlCompiler::buildPropertyObjectAssignment(QmlParser::Property *prop,
return true;
}
-// Compile assigning a literal or binding to a regular property
+// Compile assigning a literal or binding to a regular property
bool QmlCompiler::buildPropertyLiteralAssignment(QmlParser::Property *prop,
QmlParser::Object *obj,
QmlParser::Value *v,
@@ -1762,16 +1762,16 @@ bool QmlCompiler::checkDynamicMeta(QmlParser::Object *obj)
// Check properties
for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) {
- const QmlParser::Object::DynamicProperty &prop =
+ const QmlParser::Object::DynamicProperty &prop =
obj->dynamicProperties.at(ii);
if (prop.isDefaultProperty) {
if (seenDefaultProperty)
COMPILE_EXCEPTION(obj, "Duplicate default property");
seenDefaultProperty = true;
- }
-
- if (propNames.contains(prop.name))
+ }
+
+ if (propNames.contains(prop.name))
COMPILE_EXCEPTION(obj, "Duplicate property name");
propNames.insert(prop.name);
@@ -1802,7 +1802,7 @@ bool QmlCompiler::mergeDynamicMetaProperties(QmlParser::Object *obj)
continue;
Property *property = 0;
- if (p.isDefaultProperty)
+ if (p.isDefaultProperty)
property = obj->getDefaultProperty();
else
property = obj->getProperty(p.name);
@@ -1821,7 +1821,7 @@ bool QmlCompiler::mergeDynamicMetaProperties(QmlParser::Object *obj)
bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode)
{
- if (obj->dynamicProperties.isEmpty() &&
+ if (obj->dynamicProperties.isEmpty() &&
obj->dynamicSignals.isEmpty() &&
obj->dynamicSlots.isEmpty())
return true;
@@ -1839,7 +1839,7 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode)
for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) {
const Object::DynamicProperty &p = obj->dynamicProperties.at(ii);
- int propIdx =
+ int propIdx =
obj->metaObject()->indexOfProperty(p.name.constData());
if (-1 != propIdx) {
QMetaProperty prop = obj->metaObject()->property(propIdx);
@@ -1847,8 +1847,8 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode)
COMPILE_EXCEPTION(&p, "Cannot override FINAL property");
}
- if (p.isDefaultProperty &&
- (p.type != Object::DynamicProperty::Alias ||
+ if (p.isDefaultProperty &&
+ (p.type != Object::DynamicProperty::Alias ||
mode == ResolveAliases))
builder.addClassInfo("DefaultProperty", p.name);
@@ -1937,7 +1937,7 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode)
b.setParameterNames(s.parameterNames);
((QmlVMEMetaData *)dynamicData.data())->methodCount++;
- QmlVMEMetaData::MethodData methodData =
+ QmlVMEMetaData::MethodData methodData =
{ s.parameterNames.count(), 0, s.body.length(), 0 };
dynamicData.append((char *)&methodData, sizeof(methodData));
@@ -1945,19 +1945,19 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode)
for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) {
const Object::DynamicSlot &s = obj->dynamicSlots.at(ii);
- QmlVMEMetaData::MethodData *data =
+ QmlVMEMetaData::MethodData *data =
((QmlVMEMetaData *)dynamicData.data())->methodData() + ii;
data->bodyOffset = dynamicData.size();
- dynamicData.append((const char *)s.body.constData(),
+ dynamicData.append((const char *)s.body.constData(),
(s.body.length() * sizeof(QChar)));
}
obj->metadata = builder.toRelocatableData();
builder.fromRelocatableData(&obj->extObject, obj->metatype, obj->metadata);
- if (mode == IgnoreAliases && hasAlias)
+ if (mode == IgnoreAliases && hasAlias)
compileState.aliasingObjects << obj;
obj->synthdata = dynamicData;
@@ -1969,7 +1969,7 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode)
static QStringList astNodeToStringList(QmlJS::AST::Node *node)
{
if (node->kind == QmlJS::AST::Node::Kind_IdentifierExpression) {
- QString name =
+ QString name =
static_cast<QmlJS::AST::IdentifierExpression *>(node)->name->asString();
return QStringList() << name;
} else if (node->kind == QmlJS::AST::Node::Kind_FieldMemberExpression) {
@@ -1980,13 +1980,13 @@ static QStringList astNodeToStringList(QmlJS::AST::Node *node)
return rv;
rv.append(expr->name->asString());
return rv;
- }
+ }
return QStringList();
}
-bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder,
+bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder,
QByteArray &data,
- Object *obj,
+ Object *obj,
const Object::DynamicProperty &prop)
{
if (!prop.defaultValue)
@@ -1994,27 +1994,27 @@ bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder,
if (prop.defaultValue->values.count() != 1 ||
prop.defaultValue->values.at(0)->object ||
- !prop.defaultValue->values.at(0)->value.isScript())
+ !prop.defaultValue->values.at(0)->value.isScript())
COMPILE_EXCEPTION(prop.defaultValue, "Invalid alias location");
QmlJS::AST::Node *node = prop.defaultValue->values.at(0)->value.asAST();
- if (!node)
+ if (!node)
COMPILE_EXCEPTION(obj, "No property alias location"); // ### Can this happen?
QStringList alias = astNodeToStringList(node);
- if (alias.count() != 2)
+ if (alias.count() != 2)
COMPILE_EXCEPTION(prop.defaultValue, "Invalid alias location");
- if (!compileState.ids.contains(alias.at(0)))
+ if (!compileState.ids.contains(alias.at(0)))
COMPILE_EXCEPTION(prop.defaultValue, "Invalid alias location");
Object *idObject = compileState.ids[alias.at(0)];
int propIdx = idObject->metaObject()->indexOfProperty(alias.at(1).toUtf8().constData());
- if (-1 == propIdx)
+ if (-1 == propIdx)
COMPILE_EXCEPTION(prop.defaultValue, "Invalid alias location");
-
+
QMetaProperty aliasProperty = idObject->metaObject()->property(propIdx);
data.append((const char *)&idObject->idIndex, sizeof(idObject->idIndex));
@@ -2025,7 +2025,7 @@ bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder,
return true;
}
-bool QmlCompiler::buildBinding(QmlParser::Value *value,
+bool QmlCompiler::buildBinding(QmlParser::Value *value,
QmlParser::Property *prop,
const BindingContext &ctxt)
{
@@ -2035,7 +2035,7 @@ bool QmlCompiler::buildBinding(QmlParser::Value *value,
QMetaProperty mp = prop->parent->metaObject()->property(prop->index);
if (!mp.isWritable() && !QmlMetaType::isList(prop->type))
- COMPILE_EXCEPTION(prop, "Invalid property assignment: read-only property");
+ COMPILE_EXCEPTION(prop, "Invalid property assignment: read-only property");
BindingReference reference;
reference.expression = value->value;
@@ -2047,11 +2047,12 @@ bool QmlCompiler::buildBinding(QmlParser::Value *value,
return true;
}
-void QmlCompiler::genBindingAssignment(QmlParser::Value *binding,
- QmlParser::Property *prop,
+void QmlCompiler::genBindingAssignment(QmlParser::Value *binding,
+ QmlParser::Property *prop,
QmlParser::Object *obj,
QmlParser::Property *valueTypeProperty)
{
+ Q_UNUSED(obj);
Q_ASSERT(compileState.bindings.contains(binding));
const BindingReference &ref = compileState.bindings.value(binding);
@@ -2069,11 +2070,11 @@ void QmlCompiler::genBindingAssignment(QmlParser::Value *binding,
Q_ASSERT(ref.bindingContext.owner == 0 ||
(ref.bindingContext.owner != 0 && valueTypeProperty));
if (ref.bindingContext.owner) {
- store.assignBinding.property =
- QmlMetaPropertyPrivate::saveValueType(valueTypeProperty->index,
+ store.assignBinding.property =
+ QmlMetaPropertyPrivate::saveValueType(valueTypeProperty->index,
prop->index);
} else {
- store.assignBinding.property =
+ store.assignBinding.property =
QmlMetaPropertyPrivate::saveProperty(prop->index);
}
store.assignBinding.value = dataRef;
@@ -2106,8 +2107,8 @@ bool QmlCompiler::completeComponentBuild()
expr.expression = binding.expression;
bs.compile(expr);
- if (bs.isValid())
- binding.compiledData =
+ if (bs.isValid())
+ binding.compiledData =
QByteArray(bs.compileData(), bs.compileDataSize());
}
@@ -2115,12 +2116,12 @@ bool QmlCompiler::completeComponentBuild()
}
/*!
- Returns true if from can be assigned to a (QObject) property of type
+ Returns true if from can be assigned to a (QObject) property of type
to.
*/
bool QmlCompiler::canCoerce(int to, QmlParser::Object *from)
{
- const QMetaObject *toMo =
+ const QMetaObject *toMo =
QmlMetaType::rawMetaObjectForType(to);
const QMetaObject *fromMo = from->metaObject();
@@ -2135,7 +2136,7 @@ bool QmlCompiler::canCoerce(int to, QmlParser::Object *from)
QmlType *QmlCompiler::toQmlType(QmlParser::Object *from)
{
// ### Optimize
- const QMetaObject *mo = from->metatype;
+ const QMetaObject *mo = from->metatype;
QmlType *type = 0;
while (!type && mo) {
type = QmlMetaType::qmlType(mo);
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 321feb9..f6d70e0 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -94,12 +94,12 @@ struct StaticQtMetaObject : public QObject
};
QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
-: rootContext(0), currentBindContext(0), currentExpression(0),
+: rootContext(0), currentBindContext(0), currentExpression(0),
isDebugging(false), contextClass(0), objectClass(0), valueTypeClass(0),
scriptEngine(this), rootComponent(0), networkAccessManager(0), typeManager(e),
uniqueId(1)
{
- QScriptValue qtObject =
+ QScriptValue qtObject =
scriptEngine.newQMetaObject(StaticQtMetaObject::get());
scriptEngine.globalObject().setProperty(QLatin1String("Qt"), qtObject);
}
@@ -115,7 +115,7 @@ QmlEnginePrivate::~QmlEnginePrivate()
delete networkAccessManager;
networkAccessManager = 0;
- for(int ii = 0; ii < bindValues.count(); ++ii)
+ for(int ii = 0; ii < bindValues.count(); ++ii)
clear(bindValues[ii]);
for(int ii = 0; ii < parserStatus.count(); ++ii)
clear(parserStatus[ii]);
@@ -126,7 +126,7 @@ void QmlEnginePrivate::clear(SimpleList<QmlBinding> &bvs)
for (int ii = 0; ii < bvs.count; ++ii) {
QmlBinding *bv = bvs.at(ii);
if(bv) {
- QmlBindingPrivate *p =
+ QmlBindingPrivate *p =
static_cast<QmlBindingPrivate *>(QObjectPrivate::get(bv));
p->mePtr = 0;
}
@@ -138,7 +138,7 @@ void QmlEnginePrivate::clear(SimpleList<QmlParserStatus> &pss)
{
for (int ii = 0; ii < pss.count; ++ii) {
QmlParserStatus *ps = pss.at(ii);
- if(ps)
+ if(ps)
ps->d = 0;
}
pss.clear();
@@ -166,7 +166,7 @@ void QmlEnginePrivate::init()
scriptEngine.globalObject().setProperty(QLatin1String("createComponent"),
scriptEngine.newFunction(QmlEnginePrivate::createComponent, 1));
- if (QCoreApplication::instance()->thread() == q->thread() &&
+ if (QCoreApplication::instance()->thread() == q->thread() &&
QmlEngineDebugServer::isDebuggingEnabled()) {
qmlEngineDebugServer();
isDebugging = true;
@@ -196,7 +196,7 @@ QmlEnginePrivate::queryObject(const QString &propName,
{
QScriptClass::QueryFlags rv = 0;
- QmlMetaProperty prop(obj, propName);
+ QmlMetaProperty prop(obj, propName, rootContext);
if (prop.type() == QmlMetaProperty::Invalid) {
QPair<const QMetaObject *, QString> key =
qMakePair(obj->metaObject(), propName);
@@ -279,14 +279,14 @@ QScriptValue QmlEnginePrivate::propertyObject(const QScriptString &propName,
\brief The QmlEngine class provides an environment for instantiating QML components.
\mainclass
- Each QML component is instantiated in a QmlContext. QmlContext's are
+ Each QML component is instantiated in a QmlContext. QmlContext's are
essential for passing data to QML components. In QML, contexts are arranged
hierarchically and this hierarchy is managed by the QmlEngine.
Prior to creating any QML components, an application must have created a
QmlEngine to gain access to a QML context. The following example shows how
to create a simple Text item.
-
+
\code
QmlEngine engine;
QmlComponent component(&engine, "Text { text: \"Hello world!\" }");
@@ -317,7 +317,7 @@ QmlEngine::QmlEngine(QObject *parent)
/*!
Destroys the QmlEngine.
- Any QmlContext's created on this engine will be invalidated, but not
+ Any QmlContext's created on this engine will be invalidated, but not
destroyed (unless they are parented to the QmlEngine object).
*/
QmlEngine::~QmlEngine()
@@ -340,13 +340,13 @@ void QmlEngine::clearComponentCache()
}
/*!
- Returns the engine's root context.
+ Returns the engine's root context.
- The root context is automatically created by the QmlEngine. Data that
+ The root context is automatically created by the QmlEngine. Data that
should be available to all QML component instances instantiated by the
engine should be put in the root context.
- Additional data that should only be available to a subset of component
+ Additional data that should only be available to a subset of component
instances should be added to sub-contexts parented to the root context.
*/
QmlContext *QmlEngine::rootContext()
@@ -374,13 +374,13 @@ void QmlEngine::setNetworkAccessManager(QNetworkAccessManager *network)
Returns the common QNetworkAccessManager used by all QML elements
instantiated by this engine.
- The default implements no caching, cookiejar, etc., just a default
+ The default implements no caching, cookiejar, etc., just a default
QNetworkAccessManager.
*/
QNetworkAccessManager *QmlEngine::networkAccessManager() const
{
Q_D(const QmlEngine);
- if (!d->networkAccessManager)
+ if (!d->networkAccessManager)
d->networkAccessManager = new QNetworkAccessManager;
return d->networkAccessManager;
}
@@ -389,7 +389,7 @@ QNetworkAccessManager *QmlEngine::networkAccessManager() const
Return the base URL for this engine. The base URL is only used to resolve
components when a relative URL is passed to the QmlComponent constructor.
- If a base URL has not been explicitly set, this method returns the
+ If a base URL has not been explicitly set, this method returns the
application's current working directory.
\sa setBaseUrl()
@@ -405,7 +405,7 @@ QUrl QmlEngine::baseUrl() const
}
/*!
- Set the base URL for this engine to \a url.
+ Set the base URL for this engine to \a url.
\sa baseUrl()
*/
@@ -427,7 +427,7 @@ QmlContext *QmlEngine::contextForObject(const QObject *object)
QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
- QmlSimpleDeclarativeData *data =
+ QmlSimpleDeclarativeData *data =
static_cast<QmlSimpleDeclarativeData *>(priv->declarativeData);
return data?data->context:0;
@@ -444,7 +444,7 @@ void QmlEngine::setContextForObject(QObject *object, QmlContext *context)
{
QObjectPrivate *priv = QObjectPrivate::get(object);
- QmlSimpleDeclarativeData *data =
+ QmlSimpleDeclarativeData *data =
static_cast<QmlSimpleDeclarativeData *>(priv->declarativeData);
if (data && data->context) {
@@ -487,7 +487,7 @@ QmlEngine *qmlEngine(const QObject *obj)
QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool create)
{
- QmlExtendedDeclarativeData *edata =
+ QmlExtendedDeclarativeData *edata =
QmlExtendedDeclarativeData::get(const_cast<QObject *>(object), true);
QObject *rv = edata->attachedProperties.value(id);
@@ -500,7 +500,7 @@ QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool cre
rv = pf(const_cast<QObject *>(object));
- if (rv)
+ if (rv)
edata->attachedProperties.insert(id, rv);
return rv;
@@ -508,7 +508,7 @@ QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool cre
void QmlSimpleDeclarativeData::destroyed(QObject *object)
{
- if (context)
+ if (context)
context->d_func()->contextObjects.removeAll(object);
}
@@ -537,7 +537,7 @@ QScriptEngine *QmlEngine::scriptEngine()
to the special needs of QML requiring more functionality than a standard
QtScript QObject.
*/
-QScriptValue QmlEnginePrivate::qmlScriptObject(QObject* object,
+QScriptValue QmlEnginePrivate::qmlScriptObject(QObject* object,
QmlEngine* engine)
{
QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
@@ -597,12 +597,12 @@ QScriptValue QmlEnginePrivate::qmlScriptObject(QObject* object,
If you want to just create an arbitrary string of QML, instead of
loading a qml file, consider the createQmlObject() function.
*/
-QScriptValue QmlEnginePrivate::createComponent(QScriptContext *ctxt,
+QScriptValue QmlEnginePrivate::createComponent(QScriptContext *ctxt,
QScriptEngine *engine)
{
QmlComponentJS* c;
- QmlEnginePrivate *activeEnginePriv =
+ QmlEnginePrivate *activeEnginePriv =
static_cast<QmlScriptEngine*>(engine)->p;
QmlEngine* activeEngine = activeEnginePriv->q_func();
@@ -646,11 +646,11 @@ QScriptValue QmlEnginePrivate::createComponent(QScriptContext *ctxt,
*/
QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine)
{
- QmlEnginePrivate *activeEnginePriv =
+ QmlEnginePrivate *activeEnginePriv =
static_cast<QmlScriptEngine*>(engine)->p;
QmlEngine* activeEngine = activeEnginePriv->q_func();
- if(ctxt->argumentCount() < 2)
+ if(ctxt->argumentCount() < 2)
return engine->nullValue();
QString qml = ctxt->argument(0).toString();
@@ -664,7 +664,7 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi
if(component.isError()) {
QList<QmlError> errors = component.errors();
qWarning() <<"QmlEngine::createQmlObject():";
- foreach (const QmlError &error, errors)
+ foreach (const QmlError &error, errors)
qWarning() << " " << error;
return engine->nullValue();
@@ -675,7 +675,7 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi
if(component.isError()) {
QList<QmlError> errors = component.errors();
qWarning() <<"QmlEngine::createQmlObject():";
- foreach (const QmlError &error, errors)
+ foreach (const QmlError &error, errors)
qWarning() << " " << error;
return engine->nullValue();
@@ -690,14 +690,14 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi
}
QmlScriptClass::QmlScriptClass(QmlEngine *bindengine)
-: QScriptClass(QmlEnginePrivate::getScriptEngine(bindengine)),
+: QScriptClass(QmlEnginePrivate::getScriptEngine(bindengine)),
engine(bindengine)
{
}
QVariant QmlScriptClass::toVariant(QmlEngine *engine, const QScriptValue &val)
{
- QmlEnginePrivate *ep =
+ QmlEnginePrivate *ep =
static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine));
QScriptClass *sc = val.scriptClass();
@@ -708,12 +708,12 @@ QVariant QmlScriptClass::toVariant(QmlEngine *engine, const QScriptValue &val)
} else if (sc == ep->objectClass) {
return QVariant::fromValue(val.data().toQObject());
} else if (sc == ep->valueTypeClass) {
- QmlValueTypeReference ref =
+ QmlValueTypeReference ref =
qvariant_cast<QmlValueTypeReference>(val.data().toVariant());
if (!ref.object)
return QVariant();
-
+
QMetaProperty p = ref.object->metaObject()->property(ref.property);
return p.read(ref.object);
}
@@ -735,13 +735,13 @@ QmlContextScriptClass::~QmlContextScriptClass()
{
}
-QScriptClass::QueryFlags
+QScriptClass::QueryFlags
QmlContextScriptClass::queryProperty(const QScriptValue &object,
const QScriptString &name,
QueryFlags flags, uint *id)
{
Q_UNUSED(flags);
- QmlContext *bindContext =
+ QmlContext *bindContext =
static_cast<QmlContext*>(object.data().toQObject());
QueryFlags rv = 0;
@@ -755,11 +755,11 @@ QmlContextScriptClass::queryProperty(const QScriptValue &object,
if (bindContext->d_func()->propertyNames.contains(propName)) {
rv |= HandlesReadAccess;
*id = VariantPropertyId;
- }
+ }
for (int ii = 0; !rv && ii < bindContext->d_func()->defaultObjects.count(); ++ii) {
rv = QmlEnginePrivate::get(engine)->queryObject(propName, id, bindContext->d_func()->defaultObjects.at(ii));
- if (rv)
+ if (rv)
*id |= (ii << 24);
}
@@ -767,10 +767,10 @@ QmlContextScriptClass::queryProperty(const QScriptValue &object,
}
QScriptValue QmlContextScriptClass::property(const QScriptValue &object,
- const QScriptString &name,
+ const QScriptString &name,
uint id)
{
- QmlContext *bindContext =
+ QmlContext *bindContext =
static_cast<QmlContext*>(object.data().toQObject());
#ifdef PROPERTY_DEBUG
@@ -829,7 +829,7 @@ void QmlContextScriptClass::setProperty(QScriptValue &object,
{
Q_UNUSED(name);
- QmlContext *bindContext =
+ QmlContext *bindContext =
static_cast<QmlContext*>(object.data().toQObject());
#ifdef PROPERTY_DEBUG
@@ -863,12 +863,13 @@ QmlValueTypeScriptClass::~QmlValueTypeScriptClass()
{
}
-QmlValueTypeScriptClass::QueryFlags
+QmlValueTypeScriptClass::QueryFlags
QmlValueTypeScriptClass::queryProperty(const QScriptValue &object,
const QScriptString &name,
QueryFlags flags, uint *id)
{
- QmlValueTypeReference ref =
+ Q_UNUSED(flags);
+ QmlValueTypeReference ref =
qvariant_cast<QmlValueTypeReference>(object.data().toVariant());
if (!ref.object)
@@ -883,7 +884,7 @@ QmlValueTypeScriptClass::queryProperty(const QScriptValue &object,
QMetaProperty prop = ref.object->metaObject()->property(idx);
- QmlValueTypeScriptClass::QueryFlags rv =
+ QmlValueTypeScriptClass::QueryFlags rv =
QmlValueTypeScriptClass::HandlesReadAccess;
if (prop.isWritable())
rv |= QmlValueTypeScriptClass::HandlesWriteAccess;
@@ -892,10 +893,11 @@ QmlValueTypeScriptClass::queryProperty(const QScriptValue &object,
}
QScriptValue QmlValueTypeScriptClass::property(const QScriptValue &object,
- const QScriptString &name,
+ const QScriptString &name,
uint id)
{
- QmlValueTypeReference ref =
+ Q_UNUSED(name);
+ QmlValueTypeReference ref =
qvariant_cast<QmlValueTypeReference>(object.data().toVariant());
if (!ref.object)
@@ -914,7 +916,8 @@ void QmlValueTypeScriptClass::setProperty(QScriptValue &object,
uint id,
const QScriptValue &value)
{
- QmlValueTypeReference ref =
+ Q_UNUSED(name);
+ QmlValueTypeReference ref =
qvariant_cast<QmlValueTypeReference>(object.data().toVariant());
if (!ref.object)
@@ -983,7 +986,7 @@ QScriptClass::QueryFlags QmlObjectScriptClass::queryProperty(const QScriptValue
}
QScriptValue QmlObjectScriptClass::property(const QScriptValue &object,
- const QScriptString &name,
+ const QScriptString &name,
uint id)
{
QObject *obj = object.data().toQObject();
@@ -993,7 +996,7 @@ QScriptValue QmlObjectScriptClass::property(const QScriptValue &object,
qWarning() << "QmlObject Property:" << propName << obj;
#endif
- QScriptValue rv =
+ QScriptValue rv =
QmlEnginePrivate::get(engine)->propertyObject(name, obj, id);
if (rv.isValid()) {
#ifdef PROPERTY_DEBUG
@@ -1227,7 +1230,7 @@ void QmlEnginePrivate::Imports::setBaseUrl(const QUrl& url)
*/
void QmlEngine::addImportPath(const QString& path)
{
- if (qmlImportTrace())
+ if (qmlImportTrace())
qDebug() << "QmlEngine::addImportPath" << path;
Q_D(QmlEngine);
d->fileImportPath.prepend(path);
@@ -1250,7 +1253,7 @@ void QmlEngine::addImportPath(const QString& path)
bool QmlEnginePrivate::addToImport(Imports* imports, const QString& uri, const QString& prefix, const QString& version, QmlScriptParser::Import::Type importType) const
{
bool ok = imports->d->add(imports->base,uri,prefix,version,importType,fileImportPath);
- if (qmlImportTrace())
+ if (qmlImportTrace())
qDebug() << "QmlEngine::addToImport(" << imports << uri << prefix << version << (importType==QmlScriptParser::Import::Library? "Library" : "File") << ": " << ok;
return ok;
}
@@ -1279,7 +1282,7 @@ bool QmlEnginePrivate::resolveType(const Imports& imports, const QByteArray& typ
if (!t) t = QmlMetaType::qmlType(type);
if (t) {
if (type_return) *type_return = t;
- if (qmlImportTrace())
+ if (qmlImportTrace())
qDebug() << "QmlEngine::resolveType" << type << "= (builtin)";
return true;
}
@@ -1291,12 +1294,12 @@ bool QmlEnginePrivate::resolveType(const Imports& imports, const QByteArray& typ
if (url.isValid()) {
if (url_return) *url_return = url;
- if (qmlImportTrace())
+ if (qmlImportTrace())
qDebug() << "QmlEngine::resolveType" << type << "=" << url;
return true;
}
}
- if (qmlImportTrace())
+ if (qmlImportTrace())
qDebug() << "QmlEngine::resolveType" << type << " not found";
return false;
}
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index 18cdd83..dffae6c 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -71,6 +71,7 @@
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlexpression.h>
#include <QtScript/qscriptengine.h>
+#include <private/qmlmetaproperty_p.h>
QT_BEGIN_NAMESPACE
@@ -177,6 +178,7 @@ public:
}
QmlValueTypeFactory valueTypes;
+ QHash<const QMetaObject *, QmlMetaObjectCache> propertyCache;
struct Imports {
Imports();
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index 3d040e5..e6ffd50 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -56,31 +56,27 @@ Q_DECLARE_METATYPE(QList<QObject *>);
QT_BEGIN_NAMESPACE
-class QMetaPropertyEx : public QMetaProperty
+QmlMetaObjectCache::Data
+QmlMetaObjectCache::property(const QString &name, const QMetaObject *metaObject)
{
-public:
- QMetaPropertyEx()
- : propertyType(-1) {}
-
- QMetaPropertyEx(const QMetaProperty &p)
- : QMetaProperty(p), propertyType(p.userType()) {}
-
- QMetaPropertyEx(const QMetaPropertyEx &o)
- : QMetaProperty(o),
- propertyType(o.propertyType) {}
-
- QMetaPropertyEx &operator=(const QMetaPropertyEx &o)
- {
- static_cast<QMetaProperty *>(this)->operator=(o);
- propertyType = o.propertyType;
- return *this;
- }
+ QHash<QString, Data>::ConstIterator iter = properties.find(name);
+ if (iter != properties.end()) {
+ return *iter;
+ } else {
+ Data cacheData = { -1, -1 };
- private:
- friend class QmlMetaProperty;
- int propertyType;
-};
+ int idx = metaObject->indexOfProperty(name.toUtf8().constData());
+ if (idx == -1)
+ return cacheData;
+ QMetaProperty property = metaObject->property(idx);
+ cacheData.propType = property.userType();
+ cacheData.coreIndex = idx;
+ properties.insert(name, cacheData);
+
+ return cacheData;
+ }
+}
/*!
\class QmlMetaProperty
@@ -111,16 +107,13 @@ struct CachedPropertyData {
int coreIdx;
};
-// ### not thread safe
-static QHash<const QMetaObject *, CachedPropertyData> qmlCacheDefProp;
-
/*!
Creates a QmlMetaProperty for the default property of \a obj. If there is no
default property, an invalid QmlMetaProperty will be created.
*/
QmlMetaProperty::QmlMetaProperty(QObject *obj)
{
- initDefault(obj);
+ d->initDefault(obj);
}
/*!
@@ -132,32 +125,24 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, QmlContext *ctxt)
: d(new QmlMetaPropertyPrivate)
{
d->context = ctxt;
- initDefault(obj);
+ d->initDefault(obj);
}
-void QmlMetaProperty::initDefault(QObject *obj)
+/*!
+ Initialize from the default property of \a obj
+*/
+void QmlMetaPropertyPrivate::initDefault(QObject *obj)
{
if (!obj)
return;
- d->object = obj;
- QHash<const QMetaObject *, CachedPropertyData>::ConstIterator iter =
- qmlCacheDefProp.find(obj->metaObject());
- if (iter != qmlCacheDefProp.end()) {
- d->name = iter->name;
- d->propType = iter->propType;
- d->coreIdx = iter->coreIdx;
- } else {
- QMetaPropertyEx p(QmlMetaType::defaultProperty(obj));
- d->name = QLatin1String(p.name());
- d->propType = p.propertyType;
- d->coreIdx = p.propertyIndex();
- if (!QObjectPrivate::get(obj)->metaObject)
- qmlCacheDefProp.insert(obj->metaObject(), CachedPropertyData(d->name, d->propType, d->coreIdx));
- }
- if (!d->name.isEmpty()) {
- d->type = Property | Default;
- }
+ object = obj;
+ QMetaProperty p = QmlMetaType::defaultProperty(obj);
+ name = QLatin1String(p.name());
+ propType = p.userType();;
+ coreIdx = p.propertyIndex();
+ if (!name.isEmpty())
+ type = QmlMetaProperty::Property | QmlMetaProperty::Default;
}
/*!
@@ -171,22 +156,20 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, int idx, QmlContext *ctxt)
d->context = ctxt;
d->object = obj;
d->type = Property;
- QMetaPropertyEx p(obj->metaObject()->property(idx));
- d->propType = p.propertyType;
+ QMetaProperty p = obj->metaObject()->property(idx);
+ d->propType = p.userType();
d->coreIdx = idx;
if (p.name() != 0)
d->name = QLatin1String(p.name());
}
-// ### Not thread safe!!!!
-static QHash<const QMetaObject *, QHash<QString, CachedPropertyData> > qmlCacheProps;
/*!
Creates a QmlMetaProperty for the property \a name of \a obj.
*/
QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name)
: d(new QmlMetaPropertyPrivate)
{
- initProperty(obj, name);
+ d->initProperty(obj, name);
}
/*!
@@ -197,51 +180,62 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name, QmlContext *
: d(new QmlMetaPropertyPrivate)
{
d->context = ctxt;
- initProperty(obj, name);
+ d->initProperty(obj, name);
}
-void QmlMetaProperty::initProperty(QObject *obj, const QString &name)
+void QmlMetaPropertyPrivate::initProperty(QObject *obj, const QString &name)
{
- d->name = name;
- d->object = obj;
+ QmlEnginePrivate *enginePrivate = 0;
+ if (context && context->engine())
+ enginePrivate = QmlEnginePrivate::get(context->engine());
+
+ this->name = name;
+ object = obj;
+
if (name.isEmpty() || !obj)
return;
if (name.at(0).isUpper()) {
// Attached property
- d->attachedFunc = QmlMetaType::attachedPropertiesFuncId(name.toLatin1());
- if (d->attachedFunc != -1)
- d->type = Property | Attached;
+ attachedFunc = QmlMetaType::attachedPropertiesFuncId(name.toLatin1());
+ if (attachedFunc != -1)
+ type = QmlMetaProperty::Property | QmlMetaProperty::Attached;
return;
- } else if (name.count() >= 3 && name.startsWith(QLatin1String("on")) && name.at(2).isUpper()) {
+
+ } else if (name.count() >= 3 &&
+ name.at(0) == QChar(QLatin1Char('o')) &&
+ name.at(1) == QChar(QLatin1Char('n')) &&
+ name.at(2).isUpper()) {
// Signal
QString signalName = name.mid(2);
signalName[0] = signalName.at(0).toLower();
- d->findSignalInt(obj, signalName);
- if (d->signal.signature() != 0) {
- d->type = SignalProperty;
+ findSignalInt(obj, signalName);
+ if (signal.signature() != 0) {
+ type = QmlMetaProperty::SignalProperty;
return;
}
}
// Property
- QHash<QString, CachedPropertyData> &props = qmlCacheProps[obj->metaObject()];
- QHash<QString, CachedPropertyData>::ConstIterator iter = props.find(name);
- if (iter != props.end()) {
- d->name = iter->name;
- d->propType = iter->propType;
- d->coreIdx = iter->coreIdx;
+ if (!QObjectPrivate::get(obj)->metaObject && enginePrivate) {
+ // Can cache
+ QmlMetaObjectCache &cache =
+ enginePrivate->propertyCache[obj->metaObject()];
+ QmlMetaObjectCache::Data data = cache.property(name, obj->metaObject());
+ if (data.coreIndex != -1) {
+ type = QmlMetaProperty::Property;
+ propType = data.propType;
+ coreIdx = data.coreIndex;
+ }
} else {
- QMetaPropertyEx p = QmlMetaType::property(obj, name.toLatin1().constData());
- d->name = QLatin1String(p.name());
- d->propType = p.propertyType;
- d->coreIdx = p.propertyIndex();
- if (!QObjectPrivate::get(obj)->metaObject)
- props.insert(name, CachedPropertyData(d->name, d->propType, d->coreIdx));
+ // Can't cache
+ QMetaProperty p = QmlMetaType::property(obj, name.toUtf8().constData());
+ propType = p.userType();
+ coreIdx = p.propertyIndex();
+ if (p.name())
+ type = QmlMetaProperty::Property;
}
- if (!d->name.isEmpty())
- d->type = Property;
}
/*!
@@ -1037,18 +1031,18 @@ void QmlMetaProperty::restore(quint32 id, QObject *obj, QmlContext *ctxt)
QmlValueType *valueType = qmlValueTypes()->valueTypes[p.type()];
- QMetaPropertyEx p2(valueType->metaObject()->property(valueTypeIdx));
+ QMetaProperty p2(valueType->metaObject()->property(valueTypeIdx));
d->name = QLatin1String(p2.name());
- d->propType = p2.propertyType;
+ d->propType = p2.userType();
d->coreIdx = coreIdx;
d->valueTypeIdx = valueTypeIdx;
d->valueTypeId = p.type();
} else if (d->type & Property) {
- QMetaPropertyEx p(obj->metaObject()->property(id));
+ QMetaProperty p(obj->metaObject()->property(id));
d->name = QLatin1String(p.name());
- d->propType = p.propertyType;
+ d->propType = p.userType();
d->coreIdx = id;
} else if (d->type & SignalProperty) {
d->signal = obj->metaObject()->method(id);
@@ -1086,7 +1080,7 @@ QmlMetaProperty QmlMetaProperty::createProperty(QObject *obj,
QmlMetaProperty prop(object, pathName);
if (jj == path.count() - 2 &&
- prop.propertyType() < QVariant::UserType &&
+ prop.propertyType() < (int)QVariant::UserType &&
qmlValueTypes()->valueTypes[prop.propertyType()]) {
// We're now at a value type property
QObject *typeObject =
diff --git a/src/declarative/qml/qmlmetaproperty.h b/src/declarative/qml/qmlmetaproperty.h
index 2470d5d..434ff55 100644
--- a/src/declarative/qml/qmlmetaproperty.h
+++ b/src/declarative/qml/qmlmetaproperty.h
@@ -129,8 +129,6 @@ public:
int coreIndex() const;
private:
- void initDefault(QObject *obj);
- void initProperty(QObject *obj, const QString &name);
friend class QmlEnginePrivate;
QmlMetaPropertyPrivate *d;
};
diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h
index 64cdbae..0410dd6 100644
--- a/src/declarative/qml/qmlmetaproperty_p.h
+++ b/src/declarative/qml/qmlmetaproperty_p.h
@@ -58,6 +58,19 @@
QT_BEGIN_NAMESPACE
+class QmlMetaObjectCache
+{
+public:
+ struct Data {
+ int propType;
+ int coreIndex;
+ };
+
+ QHash<QString, Data> properties;
+
+ Data property(const QString &, const QMetaObject *);
+};
+
class QmlContext;
class QmlMetaPropertyPrivate
{
@@ -86,6 +99,9 @@ public:
mutable QmlMetaProperty::PropertyCategory category;
+ void initProperty(QObject *obj, const QString &name);
+ void initDefault(QObject *obj);
+
QObject *attachedObject() const;
void findSignalInt(QObject *, const QString &);
diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp
index a037702..5fe3eff 100644
--- a/src/declarative/qml/qmlmetatype.cpp
+++ b/src/declarative/qml/qmlmetatype.cpp
@@ -104,7 +104,7 @@ class QmlTypePrivate
{
public:
QmlTypePrivate();
-
+
void init() const;
bool m_isInterface : 1;
@@ -128,7 +128,7 @@ 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_parserStatusCast(-1), m_extFunc(0), m_extMetaObject(0), m_index(-1),
m_customParser(0), m_isSetup(false)
{
}
@@ -149,11 +149,11 @@ QmlType::QmlType(int type, int listType, int qmlListType,
}
QmlType::QmlType(int type, int listType, int qmlListType,
- QmlPrivate::Func opFunc, const char *qmlName,
- const QMetaObject *metaObject,
- QmlAttachedPropertiesFunc attachedPropertiesFunc,
+ QmlPrivate::Func opFunc, const char *qmlName,
+ const QMetaObject *metaObject,
+ QmlAttachedPropertiesFunc attachedPropertiesFunc,
const QMetaObject *attachedType,
- int parserStatusCast, QmlPrivate::CreateFunc extFunc,
+ int parserStatusCast, QmlPrivate::CreateFunc extFunc,
const QMetaObject *extMetaObject, int index,
QmlCustomParser *customParser)
: d(new QmlTypePrivate)
@@ -195,7 +195,7 @@ void QmlTypePrivate::init() const
QMetaObject *mmo = new QMetaObject;
*mmo = *m_extMetaObject;
mmo->d.superdata = mo;
- QmlProxyMetaObject::ProxyData data = { mmo, m_extFunc, 0 };
+ QmlProxyMetaObject::ProxyData data = { mmo, m_extFunc, 0, 0 };
m_metaObjects << data;
}
@@ -207,9 +207,9 @@ void QmlTypePrivate::init() const
QMetaObject *mmo = new QMetaObject;
*mmo = *t->d->m_extMetaObject;
mmo->d.superdata = m_baseMetaObject;
- if (!m_metaObjects.isEmpty())
+ if (!m_metaObjects.isEmpty())
m_metaObjects.last().metaObject->d.superdata = mmo;
- QmlProxyMetaObject::ProxyData data = { mmo, t->d->m_extFunc, 0 };
+ QmlProxyMetaObject::ProxyData data = { mmo, t->d->m_extFunc, 0, 0 };
m_metaObjects << data;
}
}
@@ -217,9 +217,9 @@ void QmlTypePrivate::init() const
}
for (int ii = 0; ii < m_metaObjects.count(); ++ii) {
- m_metaObjects[ii].propertyOffset =
+ m_metaObjects[ii].propertyOffset =
m_metaObjects.at(ii).metaObject->propertyOffset();
- m_metaObjects[ii].methodOffset =
+ m_metaObjects[ii].methodOffset =
m_metaObjects.at(ii).metaObject->methodOffset();
}
@@ -276,7 +276,7 @@ QObject *QmlType::create() const
QObject *rv = 0;
d->m_opFunc(QmlPrivate::Create, 0, v, v, (void **)&rv);
- if (rv && !d->m_metaObjects.isEmpty())
+ if (rv && !d->m_metaObjects.isEmpty())
(void *)new QmlProxyMetaObject(rv, &d->m_metaObjects);
return rv;
@@ -386,7 +386,7 @@ int QmlType::index() const
}
int QmlMetaType::registerInterface(const QmlPrivate::MetaTypeIds &id,
- QmlPrivate::Func listFunction,
+ QmlPrivate::Func listFunction,
const char *iid)
{
QWriteLocker lock(metaTypeDataLock());
@@ -404,11 +404,11 @@ int QmlMetaType::registerInterface(const QmlPrivate::MetaTypeIds &id,
if (!type->qmlTypeName().isEmpty())
data->nameToType.insert(type->qmlTypeName(), type);
- if (data->interfaces.size() < id.typeId)
+ if (data->interfaces.size() < id.typeId)
data->interfaces.resize(id.typeId + 16);
- if (data->qmllists.size() < id.qmlListId)
+ if (data->qmllists.size() < id.qmlListId)
data->qmllists.resize(id.qmlListId + 16);
- if (data->lists.size() < id.listId)
+ if (data->lists.size() < id.listId)
data->lists.resize(id.listId + 16);
data->interfaces.setBit(id.typeId, true);
data->qmllists.setBit(id.qmlListId, true);
@@ -484,16 +484,16 @@ int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QmlPrivate::Fun
data->idToType.insert(type->qListTypeId(), type);
data->idToType.insert(type->qmlListTypeId(), type);
- if (!type->qmlTypeName().isEmpty())
+ if (!type->qmlTypeName().isEmpty())
data->nameToType.insert(type->qmlTypeName(), type);
data->metaObjectToType.insert(type->baseMetaObject(), type);
-
- if (data->objects.size() <= id.typeId)
+
+ if (data->objects.size() <= id.typeId)
data->objects.resize(id.typeId + 16);
- if (data->qmllists.size() <= id.qmlListId)
+ if (data->qmllists.size() <= id.qmlListId)
data->qmllists.resize(id.qmlListId + 16);
- if (data->lists.size() <= id.listId)
+ if (data->lists.size() <= id.listId)
data->lists.resize(id.listId + 16);
data->objects.setBit(id.typeId, true);
data->qmllists.setBit(id.qmlListId, true);
@@ -518,7 +518,7 @@ QObject *QmlMetaType::toQObject(const QVariant &v)
if (!isObject(v.userType()))
return 0;
- // NOTE: This assumes a cast to QObject does not alter the
+ // NOTE: This assumes a cast to QObject does not alter the
// object pointer
QObject *rv = *(QObject **)v.constData();
return rv;
@@ -527,7 +527,7 @@ QObject *QmlMetaType::toQObject(const QVariant &v)
/*
Returns the item type for a list of type \a id.
*/
-int QmlMetaType::listType(int id)
+int QmlMetaType::listType(int id)
{
QReadLocker lock(metaTypeDataLock());
QmlMetaTypeData *data = metaTypeData();
@@ -574,7 +574,7 @@ bool QmlMetaType::append(const QVariant &list, const QVariant &item)
QmlMetaTypeData *data = metaTypeData();
QmlType *type = data->idToType.value(userType);
lock.unlock();
- if (type && type->qListTypeId() == userType &&
+ if (type && type->qListTypeId() == userType &&
item.userType() == type->typeId()) {
type->listAppend(list, item);
return true;
@@ -703,7 +703,7 @@ QmlAttachedPropertiesFunc QmlMetaType::attachedPropertiesFuncById(int id)
return data->types.at(id)->attachedPropertiesFunction();
}
-QmlAttachedPropertiesFunc
+QmlAttachedPropertiesFunc
QmlMetaType::attachedPropertiesFunc(const QByteArray &name)
{
QReadLocker lock(metaTypeDataLock());
@@ -876,8 +876,8 @@ QVariant QmlMetaType::listAt(const QVariant &v, int idx)
return 0;
}
-/*!
- A custom string convertor allows you to specify a function pointer that
+/*!
+ A custom string convertor allows you to specify a function pointer that
returns a variant of \a type. For example, if you have written your own icon
class that you want to support as an object property assignable in QML:
@@ -902,7 +902,7 @@ void QmlMetaType::registerCustomStringConverter(int type, StringConverter conver
}
/*!
- Return the custom string converter for \a type, previously installed through
+ Return the custom string converter for \a type, previously installed through
registerCustomStringConverter()
*/
QmlMetaType::StringConverter QmlMetaType::customStringConverter(int type)
diff --git a/src/declarative/qml/qmlvaluetype.cpp b/src/declarative/qml/qmlvaluetype.cpp
index e93fbc1..ca968fc 100644
--- a/src/declarative/qml/qmlvaluetype.cpp
+++ b/src/declarative/qml/qmlvaluetype.cpp
@@ -46,13 +46,13 @@ QT_BEGIN_NAMESPACE
QmlValueTypeFactory::QmlValueTypeFactory()
{
// ### Optimize
- for (int ii = 0; ii < (QVariant::UserType - 1); ++ii)
+ for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
valueTypes[ii] = valueType(ii);
}
QmlValueTypeFactory::~QmlValueTypeFactory()
{
- for (int ii = 0; ii < (QVariant::UserType - 1); ++ii)
+ for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
delete valueTypes[ii];
}
diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp
index 987ccb0..1fb321c 100644
--- a/src/declarative/util/qmlfollow.cpp
+++ b/src/declarative/util/qmlfollow.cpp
@@ -66,13 +66,13 @@ public:
qreal velocityms;
int lastTime;
qreal mass;
+ bool useMass;
qreal spring;
qreal damping;
qreal velocity;
qreal epsilon;
qreal modulus;
bool haveModulus;
- bool useMass;
bool enabled;
enum Mode {
diff --git a/src/declarative/util/qmlpalette.cpp b/src/declarative/util/qmlpalette.cpp
index 6fade03..e714bc7 100644
--- a/src/declarative/util/qmlpalette.cpp
+++ b/src/declarative/util/qmlpalette.cpp
@@ -124,6 +124,18 @@ QColor QmlPalette::base() const
}
/*!
+ \qmlproperty color Palette::text
+ The text color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QmlPalette::text() const
+{
+ Q_D(const QmlPalette);
+ return d->palette.color(d->group, QPalette::Text);
+}
+
+/*!
\qmlproperty color Palette::alternateBase
The alternate base color of the current color group.
@@ -260,27 +272,23 @@ QColor QmlPalette::darker(const QColor& color) const
}
/*!
- \qmlproperty enum Palette::colorGroup
+ \qmlproperty QPalette::ColorGroup Palette::colorGroup
- The color group of the palette. It can be one of:
- \list
- \o Active - used for the window that has focus.
- \o Inactive - used for other windows.
- \o Disabled - used for widgets that are disabled for some reason.
- \endlist
+ The color group of the palette. It can be Active, Inactive or Disabled.
+ Active is the default.
\sa QPalette::ColorGroup
*/
-QmlPalette::ColorGroup QmlPalette::colorGroup() const
+QPalette::ColorGroup QmlPalette::colorGroup() const
{
Q_D(const QmlPalette);
- return (QmlPalette::ColorGroup)int(d->group);
+ return d->group;
}
-void QmlPalette::setColorGroup(ColorGroup colorGroup)
+void QmlPalette::setColorGroup(QPalette::ColorGroup colorGroup)
{
Q_D(QmlPalette);
- d->group = (QPalette::ColorGroup)int(colorGroup);
+ d->group = colorGroup;
emit paletteChanged();
}
diff --git a/src/declarative/util/qmlpalette.h b/src/declarative/util/qmlpalette.h
index 7de5e0e..e381814 100644
--- a/src/declarative/util/qmlpalette.h
+++ b/src/declarative/util/qmlpalette.h
@@ -57,12 +57,12 @@ class Q_DECLARATIVE_EXPORT QmlPalette : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QmlPalette)
- Q_ENUMS(ColorGroup)
- Q_PROPERTY(ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged)
+ Q_PROPERTY(QPalette::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged)
Q_PROPERTY(QColor window READ window NOTIFY paletteChanged)
Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged)
Q_PROPERTY(QColor base READ base NOTIFY paletteChanged)
+ Q_PROPERTY(QColor text READ text NOTIFY paletteChanged)
Q_PROPERTY(QColor alternateBase READ alternateBase NOTIFY paletteChanged)
Q_PROPERTY(QColor button READ button NOTIFY paletteChanged)
Q_PROPERTY(QColor buttonText READ buttonText NOTIFY paletteChanged)
@@ -78,13 +78,11 @@ public:
QmlPalette(QObject *parent=0);
~QmlPalette();
- enum ColorGroup { Disabled = QPalette::Disabled, Active = QPalette::Active,
- Inactive = QPalette::Inactive, Normal = QPalette::Normal };
-
QColor window() const;
QColor windowText() const;
QColor base() const;
+ QColor text() const;
QColor alternateBase() const;
QColor button() const;
@@ -99,8 +97,8 @@ public:
QColor highlight() const;
QColor highlightedText() const;
- ColorGroup colorGroup() const;
- void setColorGroup(ColorGroup);
+ QPalette::ColorGroup colorGroup() const;
+ void setColorGroup(QPalette::ColorGroup);
// FIXME: Move to utility class?
Q_INVOKABLE QColor lighter(const QColor&) const;
diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp
index af60a6f..b5ba909 100644
--- a/src/declarative/util/qmlstate.cpp
+++ b/src/declarative/util/qmlstate.cpp
@@ -53,16 +53,16 @@ QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
-Action::Action()
+Action::Action()
: restore(true), actionDone(false), reverseEvent(false), fromBinding(0), toBinding(0), event(0),
specifiedObject(0)
{
}
-Action::Action(QObject *target, const QString &propertyName,
+Action::Action(QObject *target, const QString &propertyName,
const QVariant &value)
: restore(true), actionDone(false), reverseEvent(false), toValue(value), fromBinding(0),
- toBinding(0), event(0), specifiedObject(target),
+ toBinding(0), event(0), specifiedObject(target),
specifiedProperty(propertyName)
{
property = QmlMetaProperty::createProperty(target, propertyName);
@@ -112,6 +112,7 @@ void ActionEvent::clearReverseBindings()
bool ActionEvent::override(ActionEvent *other)
{
+ Q_UNUSED(other);
return false;
}
@@ -213,7 +214,7 @@ QmlBinding *QmlState::when() const
return d->when;
}
-void QmlState::setWhen(QmlBinding *when)
+void QmlState::setWhen(QmlBinding *when)
{
Q_D(QmlState);
d->when = when;
@@ -300,7 +301,7 @@ void QmlStatePrivate::complete()
// Generate a list of actions for this state. This includes coelescing state
// actions that this state "extends"
-QmlStateOperation::ActionList
+QmlStateOperation::ActionList
QmlStatePrivate::generateActionList(QmlStateGroup *group) const
{
QmlStateOperation::ActionList applyList;
@@ -342,7 +343,7 @@ void QmlState::cancel()
d->transitionManager.cancel();
}
-void Action::deleteFromBinding()
+void Action::deleteFromBinding()
{
if (fromBinding) {
property.setBinding(0);
@@ -362,7 +363,7 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever
d->reverting.clear();
if (revert) {
- QmlStatePrivate *revertPrivate =
+ QmlStatePrivate *revertPrivate =
static_cast<QmlStatePrivate*>(revert->d_ptr);
d->revertList = revertPrivate->revertList;
revertPrivate->revertList.clear();
@@ -419,7 +420,7 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever
}
}
}
-
+
// Any reverts from a previous state that aren't carried forth
// into this state need to be translated into apply actions
for (int ii = 0; ii < d->revertList.count(); ++ii) {
@@ -466,7 +467,7 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever
// Output for debugging
if (stateChangeDebug()) {
foreach(const Action &action, applyList) {
- qWarning() << " Action:" << action.property.object()
+ qWarning() << " Action:" << action.property.object()
<< action.property.name() << action.toValue;
}
}
diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp
index 7caf3ed..1f53bee 100644
--- a/src/declarative/util/qmlstateoperations.cpp
+++ b/src/declarative/util/qmlstateoperations.cpp
@@ -457,22 +457,22 @@ QList<Action> QmlSetAnchors::extraActions()
if (d->target) {
Action a;
a.fromValue = d->origX;
- a.property = QmlMetaProperty(d->target, "x");
+ a.property = QmlMetaProperty(d->target, QLatin1String("x"));
extra << a;
a.fromValue = d->origY;
- a.property = QmlMetaProperty(d->target, "y");
+ a.property = QmlMetaProperty(d->target, QLatin1String("y"));
extra << a;
a.fromValue = d->origWidth;
- a.property = QmlMetaProperty(d->target, "width");
+ a.property = QmlMetaProperty(d->target, QLatin1String("width"));
extra << a;
a.fromValue = d->origHeight;
- a.property = QmlMetaProperty(d->target, "height");
+ a.property = QmlMetaProperty(d->target, QLatin1String("height"));
extra << a;
}
-
+
return extra;
}
diff --git a/tests/benchmarks/declarative/qmlcomponent/myqmlobject.txt b/tests/benchmarks/declarative/qmlcomponent/myqmlobject.txt
index 05ed87a..9c3f7f8 100644
--- a/tests/benchmarks/declarative/qmlcomponent/myqmlobject.txt
+++ b/tests/benchmarks/declarative/qmlcomponent/myqmlobject.txt
@@ -1 +1,3 @@
+import Qt.test 4.6
+
MyQmlObject {}
diff --git a/tests/benchmarks/declarative/qmlcomponent/myqmlobject_binding.txt b/tests/benchmarks/declarative/qmlcomponent/myqmlobject_binding.txt
index 4dfa7c3..e6cc4cf 100644
--- a/tests/benchmarks/declarative/qmlcomponent/myqmlobject_binding.txt
+++ b/tests/benchmarks/declarative/qmlcomponent/myqmlobject_binding.txt
@@ -1,3 +1,5 @@
+import Qt.test 4.6
+
MyQmlObject {
result: value
}
diff --git a/tests/benchmarks/declarative/qmlcomponent/object.txt b/tests/benchmarks/declarative/qmlcomponent/object.txt
index 7dc75192..85e74b9 100644
--- a/tests/benchmarks/declarative/qmlcomponent/object.txt
+++ b/tests/benchmarks/declarative/qmlcomponent/object.txt
@@ -1 +1,3 @@
+import Qt 4.6
+
Object {}
diff --git a/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.2.txt b/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.2.txt
index d59104d..90db37c 100644
--- a/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.2.txt
+++ b/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.2.txt
@@ -1,3 +1,5 @@
+import Qt 4.6
+
Object {
property int a
property bool b
diff --git a/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.txt b/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.txt
index d9eb708..bb5469a 100644
--- a/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.txt
+++ b/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.txt
@@ -1,3 +1,5 @@
+import Qt 4.6
+
Object {
property int a
}
diff --git a/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp b/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp
index 60e69e2..5021bf3 100644
--- a/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp
+++ b/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp
@@ -1,3 +1,3 @@
#include "testtypes.h"
-QML_DEFINE_TYPE(MyQmlObject, MyQmlObject);
+QML_DEFINE_TYPE(Qt/test, 4, 6, 6, MyQmlObject, MyQmlObject);
diff --git a/tests/benchmarks/declarative/qmlmetaproperty/object.txt b/tests/benchmarks/declarative/qmlmetaproperty/object.txt
new file mode 100644
index 0000000..11b95e1
--- /dev/null
+++ b/tests/benchmarks/declarative/qmlmetaproperty/object.txt
@@ -0,0 +1,3 @@
+import Qt 4.6
+
+Item {}
diff --git a/tests/benchmarks/declarative/qmlmetaproperty/qmlmetaproperty.pro b/tests/benchmarks/declarative/qmlmetaproperty/qmlmetaproperty.pro
new file mode 100644
index 0000000..b4e83d7
--- /dev/null
+++ b/tests/benchmarks/declarative/qmlmetaproperty/qmlmetaproperty.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qmlmetaproperty
+QT += declarative
+
+SOURCES += tst_qmlmetaproperty.cpp
+
diff --git a/tests/benchmarks/declarative/qmlmetaproperty/synthesized_object.txt b/tests/benchmarks/declarative/qmlmetaproperty/synthesized_object.txt
new file mode 100644
index 0000000..a923a0a
--- /dev/null
+++ b/tests/benchmarks/declarative/qmlmetaproperty/synthesized_object.txt
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+Item {
+ property int blah
+}
+
diff --git a/tests/benchmarks/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/benchmarks/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
new file mode 100644
index 0000000..c22af03
--- /dev/null
+++ b/tests/benchmarks/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QmlEngine>
+#include <QmlComponent>
+#include <QmlMetaProperty>
+#include <QFile>
+#include <QDebug>
+
+//TESTED_FILES=
+
+
+class tst_qmlmetaproperty : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_qmlmetaproperty();
+ virtual ~tst_qmlmetaproperty();
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void lookup_data();
+ void lookup();
+
+private:
+ QmlEngine engine;
+};
+
+tst_qmlmetaproperty::tst_qmlmetaproperty()
+{
+}
+
+tst_qmlmetaproperty::~tst_qmlmetaproperty()
+{
+}
+
+void tst_qmlmetaproperty::init()
+{
+}
+
+void tst_qmlmetaproperty::cleanup()
+{
+}
+
+void tst_qmlmetaproperty::lookup_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QTest::newRow("Simple Object") << "object.txt";
+ QTest::newRow("Synthesized Object") << "synthesized_object.txt";
+}
+
+void tst_qmlmetaproperty::lookup()
+{
+ QFETCH(QString, file);
+
+ QmlComponent c(&engine, file);
+ QVERIFY(c.isReady());
+
+ QObject *obj = c.create();
+
+ QBENCHMARK {
+ QmlMetaProperty p(obj, "x");
+ }
+
+ delete obj;
+}
+
+QTEST_MAIN(tst_qmlmetaproperty)
+#include "tst_qmlmetaproperty.moc"