summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/declarative/qml/parser/qdeclarativejs.g2
-rw-r--r--src/declarative/qml/parser/qdeclarativejsparser_p.h2
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp44
-rw-r--r--src/doc/src/declarative/qtdeclarative.qdoc5
4 files changed, 38 insertions, 15 deletions
diff --git a/src/declarative/qml/parser/qdeclarativejs.g b/src/declarative/qml/parser/qdeclarativejs.g
index dc466aec..e709bba5 100644
--- a/src/declarative/qml/parser/qdeclarativejs.g
+++ b/src/declarative/qml/parser/qdeclarativejs.g
@@ -316,7 +316,7 @@ public:
inline DiagnosticMessage diagnosticMessage() const
{
foreach (const DiagnosticMessage &d, diagnostic_messages) {
- if (! d.kind == DiagnosticMessage::Warning)
+ if (d.kind != DiagnosticMessage::Warning)
return d;
}
diff --git a/src/declarative/qml/parser/qdeclarativejsparser_p.h b/src/declarative/qml/parser/qdeclarativejsparser_p.h
index 374c11ca..96c01b0f 100644
--- a/src/declarative/qml/parser/qdeclarativejsparser_p.h
+++ b/src/declarative/qml/parser/qdeclarativejsparser_p.h
@@ -179,7 +179,7 @@ public:
inline DiagnosticMessage diagnosticMessage() const
{
foreach (const DiagnosticMessage &d, diagnostic_messages) {
- if (! d.kind == DiagnosticMessage::Warning)
+ if (d.kind != DiagnosticMessage::Warning)
return d;
}
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 6734e0b4..d0c6517c 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -326,10 +326,14 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
instr.line = v->location.start.line;
if (prop.isEnumType()) {
int value;
- if (prop.isFlagType()) {
- value = prop.enumerator().keysToValue(string.toUtf8().constData());
- } else
- value = prop.enumerator().keyToValue(string.toUtf8().constData());
+ if (v->value.isNumber()) { //Number saved from earlier check - not valid in testLiteralAssignment
+ value = v->value.asNumber();
+ } else {
+ if (prop.isFlagType())
+ value = prop.enumerator().keysToValue(string.toUtf8().constData());
+ else
+ value = prop.enumerator().keyToValue(string.toUtf8().constData());
+ }
instr.type = QDeclarativeInstruction::StoreInteger;
instr.storeInteger.propertyIndex = prop.propertyIndex();
@@ -2203,6 +2207,12 @@ bool QDeclarativeCompiler::buildPropertyLiteralAssignment(QDeclarativeParser::Pr
return true;
}
+struct StaticQtMetaObject : public QObject
+{
+ static const QMetaObject *get()
+ { return &static_cast<StaticQtMetaObject*> (0)->staticQtMetaObject; }
+};
+
bool QDeclarativeCompiler::testQualifiedEnumAssignment(const QMetaProperty &prop,
QDeclarativeParser::Object *obj,
QDeclarativeParser::Value *v,
@@ -2235,20 +2245,32 @@ bool QDeclarativeCompiler::testQualifiedEnumAssignment(const QMetaProperty &prop
objTypeName = objType->qmlTypeName();
}
- if (!type || objTypeName != type->qmlTypeName())
+ if (!type && typeName != QLatin1String("Qt"))
return true;
QString enumValue = parts.at(1);
- int value;
- if (prop.isFlagType()) {
- value = prop.enumerator().keysToValue(enumValue.toUtf8().constData());
- } else
- value = prop.enumerator().keyToValue(enumValue.toUtf8().constData());
+ int value = -1;
+
+ if (type && objTypeName == type->qmlTypeName()) {
+ if (prop.isFlagType()) {
+ value = prop.enumerator().keysToValue(enumValue.toUtf8().constData());
+ } else {
+ value = prop.enumerator().keyToValue(enumValue.toUtf8().constData());
+ }
+ } else {
+ QByteArray enumName = enumValue.toUtf8();
+ //Special case for Qt object
+ const QMetaObject *metaObject = type ? type->metaObject() : StaticQtMetaObject::get();
+ for (int ii = metaObject->enumeratorCount() - 1; value == -1 && ii >= 0; --ii) {
+ QMetaEnum e = metaObject->enumerator(ii);
+ value = e.keyToValue(enumName.constData());
+ }
+ }
if (value == -1)
return true;
v->type = Value::Literal;
- v->value = QDeclarativeParser::Variant(enumValue);
+ v->value = QDeclarativeParser::Variant((double)value);
*isAssignment = true;
return true;
diff --git a/src/doc/src/declarative/qtdeclarative.qdoc b/src/doc/src/declarative/qtdeclarative.qdoc
index 69b15821..8b31f659 100644
--- a/src/doc/src/declarative/qtdeclarative.qdoc
+++ b/src/doc/src/declarative/qtdeclarative.qdoc
@@ -29,6 +29,7 @@
\module QtDeclarative
\title Qt Declarative Module
\ingroup modules
+ \qtvariable declarative
\brief The Qt Declarative module provides a declarative framework
for building highly dynamic, custom user interfaces.
@@ -67,7 +68,7 @@
Declares additional properties of the given \a Type as described by the
specified \a Flags.
-
+
Current the only supported type info is \c QML_HAS_ATTACHED_PROPERTIES which
declares that the \a Type supports \l {Attached Properties}.
@@ -112,7 +113,7 @@
qmlRegisterType<MySliderItem>("com.mycompany.qmlcomponents", 1, 0, "Slider");
\endcode
- Once this is registered, the type can be used in QML by importing the
+ Once this is registered, the type can be used in QML by importing the
specified module name and version number:
\qml