diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-06-10 04:57:51 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-06-10 04:57:51 (GMT) |
commit | 4dc4cfac667389efda4a43df5ff8cfa4ba305a2f (patch) | |
tree | 5c937ab2e510edb7a359b225132544d938a884a9 /src/declarative/qml | |
parent | 29496148abe8506fbf50c99e9a210095c5115a14 (diff) | |
download | Qt-4dc4cfac667389efda4a43df5ff8cfa4ba305a2f.zip Qt-4dc4cfac667389efda4a43df5ff8cfa4ba305a2f.tar.gz Qt-4dc4cfac667389efda4a43df5ff8cfa4ba305a2f.tar.bz2 |
Support URLs directly (not just as strings), so they are correctly resolved.
URLs expressed as strings (possible relative) are resolved relative to
the component in which the string expression is converted to a url value.
All items are converted to use QUrl properties, except SqlConnection, where
the databasename is only a special-case URL (this may need further consideration).
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qmlbindablevalue.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompiler.cpp | 11 | ||||
-rw-r--r-- | src/declarative/qml/qmlinstruction.cpp | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlinstruction_p.h | 6 | ||||
-rw-r--r-- | src/declarative/qml/qmlparser_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlscriptparser.cpp | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlvme.cpp | 16 | ||||
-rw-r--r-- | src/declarative/qml/qmlvmemetaobject.cpp | 3 |
8 files changed, 45 insertions, 1 deletions
diff --git a/src/declarative/qml/qmlbindablevalue.cpp b/src/declarative/qml/qmlbindablevalue.cpp index 351e0bd..de01387 100644 --- a/src/declarative/qml/qmlbindablevalue.cpp +++ b/src/declarative/qml/qmlbindablevalue.cpp @@ -220,6 +220,10 @@ void QmlBindableValue::update() } else if (d->property.propertyCategory() == QmlMetaProperty::Normal) { QVariant value = this->value(); + if (d->property.propertyType() == QVariant::Url && value.canConvert(QVariant::String) && !value.isNull()) { + // Must resolve first + value.setValue(context()->resolvedUrl(value.toString())); + } d->property.write(value); } diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index b28d7dd..8b4be2b 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -278,6 +278,14 @@ bool QmlCompiler::compileStoreInstruction(QmlInstruction &instr, instr.storeString.value = output->indexForString(string); } break; + case QVariant::Url: + { + instr.type = QmlInstruction::StoreUrl; + QUrl u = output->url.resolved(string); + instr.storeUrl.propertyIndex = prop.propertyIndex(); + instr.storeUrl.value = output->indexForString(u.toString()); + } + break; case QVariant::UInt: { instr.type = QmlInstruction::StoreInteger; @@ -1355,6 +1363,9 @@ bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj) case Object::DynamicProperty::String: type = "QString"; break; + case Object::DynamicProperty::Url: + type = "QUrl"; + break; case Object::DynamicProperty::Color: type = "QColor"; break; diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp index af1489a..3fe3a8e 100644 --- a/src/declarative/qml/qmlinstruction.cpp +++ b/src/declarative/qml/qmlinstruction.cpp @@ -85,6 +85,9 @@ void QmlCompiledComponent::dump(QmlInstruction *instr, int idx) case QmlInstruction::StoreString: qWarning() << idx << "\t" << line << "\t" << "STORE_STRING\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value); break; + case QmlInstruction::StoreUrl: + qWarning() << idx << "\t" << line << "\t" << "STORE_URL\t\t" << instr->storeUrl.propertyIndex << "\t" << instr->storeUrl.value << "\t\t" << primitives.at(instr->storeUrl.value); + break; case QmlInstruction::StoreColor: qWarning() << idx << "\t" << line << "\t" << "STORE_COLOR\t\t" << instr->storeColor.propertyIndex << "\t" << QString::number(instr->storeColor.value, 16); break; diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h index 5a1729f..7cdc1ed 100644 --- a/src/declarative/qml/qmlinstruction_p.h +++ b/src/declarative/qml/qmlinstruction_p.h @@ -76,6 +76,7 @@ public: // StoreInteger - Store a int or uint in a core property // StoreBool - Store a bool in a core property // StoreString - Store a QString in a core property + // StoreUrl - Store a QUrl in a core property // StoreColor - Store a QColor in a core property // StoreDate - Store a QDate in a core property // StoreTime - Store a QTime in a core property @@ -88,6 +89,7 @@ public: StoreInteger, /* storeInteger */ StoreBool, /* storeBool */ StoreString, /* storeString */ + StoreUrl, /* storeUrl */ StoreColor, /* storeColor */ StoreDate, /* storeDate */ StoreTime, /* storeTime */ @@ -217,6 +219,10 @@ public: } storeString; struct { int propertyIndex; + int value; + } storeUrl; + struct { + int propertyIndex; unsigned int value; } storeColor; struct { diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h index 0fdd26b..7989933 100644 --- a/src/declarative/qml/qmlparser_p.h +++ b/src/declarative/qml/qmlparser_p.h @@ -131,7 +131,7 @@ namespace QmlParser DynamicProperty(); DynamicProperty(const DynamicProperty &); - enum Type { Variant, Int, Bool, Real, String, Color, Date }; + enum Type { Variant, Int, Bool, Real, String, Url, Color, Date }; bool isDefaultProperty; Type type; diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index 5207292..cab7915 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -501,6 +501,7 @@ bool ProcessAST::visit(AST::UiPublicMember *node) { "double", Object::DynamicProperty::Real }, { "real", Object::DynamicProperty::Real }, { "string", Object::DynamicProperty::String }, + { "url", Object::DynamicProperty::Url }, { "color", Object::DynamicProperty::Color }, { "date", Object::DynamicProperty::Date }, { "var", Object::DynamicProperty::Variant }, diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index f00d282..af0b3e0 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -77,6 +77,7 @@ Q_DECLARE_PERFORMANCE_LOG(QFxCompiler) { Q_DECLARE_PERFORMANCE_METRIC(InstrStoreInteger); Q_DECLARE_PERFORMANCE_METRIC(InstrStoreBool); Q_DECLARE_PERFORMANCE_METRIC(InstrStoreString); + Q_DECLARE_PERFORMANCE_METRIC(InstrStoreUrl); Q_DECLARE_PERFORMANCE_METRIC(InstrStoreColor); Q_DECLARE_PERFORMANCE_METRIC(InstrStoreDate); Q_DECLARE_PERFORMANCE_METRIC(InstrStoreDateTime); @@ -116,6 +117,7 @@ Q_DEFINE_PERFORMANCE_LOG(QFxCompiler, "QFxCompiler") { Q_DEFINE_PERFORMANCE_METRIC(InstrStoreInteger, "StoreInteger"); Q_DEFINE_PERFORMANCE_METRIC(InstrStoreBool, "StoreBool"); Q_DEFINE_PERFORMANCE_METRIC(InstrStoreString, "StoreString"); + Q_DEFINE_PERFORMANCE_METRIC(InstrStoreUrl, "StoreUrl"); Q_DEFINE_PERFORMANCE_METRIC(InstrStoreColor, "StoreColor"); Q_DEFINE_PERFORMANCE_METRIC(InstrStoreDate, "StoreDate"); Q_DEFINE_PERFORMANCE_METRIC(InstrStoreDateTime, "StoreDateTime"); @@ -337,6 +339,20 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in } break; + case QmlInstruction::StoreUrl: + { +#ifdef Q_ENABLE_PERFORMANCE_LOG + QFxCompilerTimer<QFxCompiler::InstrStoreUrl> cc; +#endif + QObject *target = stack.top(); + void *a[1]; + QUrl u(primitives.at(instr.storeUrl.value)); + a[0] = (void *)&u; + QMetaObject::metacall(target, QMetaObject::WriteProperty, + instr.storeUrl.propertyIndex, a); + } + break; + case QmlInstruction::StoreFloat: { #ifdef Q_ENABLE_PERFORMANCE_LOG diff --git a/src/declarative/qml/qmlvmemetaobject.cpp b/src/declarative/qml/qmlvmemetaobject.cpp index 58708cf..0117448 100644 --- a/src/declarative/qml/qmlvmemetaobject.cpp +++ b/src/declarative/qml/qmlvmemetaobject.cpp @@ -134,6 +134,9 @@ int QmlVMEMetaObject::metaCall(QMetaObject::Call c, int id, void **a) case QVariant::String: *reinterpret_cast<QString *>(a[0]) = data[propId].toString(); break; + case QVariant::Url: + *reinterpret_cast<QUrl *>(a[0]) = data[propId].toUrl(); + break; case QVariant::Color: *reinterpret_cast<QColor *>(a[0]) = data[propId].value<QColor>(); break; |