From 932f667eaad727854f6bb48d797874455ed13231 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 9 Sep 2009 20:38:13 +1000 Subject: Support URL resolution from within script blocks --- src/declarative/qml/qmlbinding.cpp | 4 ---- src/declarative/qml/qmlmetaproperty.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/declarative/qml/qmlbinding.cpp b/src/declarative/qml/qmlbinding.cpp index 39851ff..f9c9561 100644 --- a/src/declarative/qml/qmlbinding.cpp +++ b/src/declarative/qml/qmlbinding.cpp @@ -126,10 +126,6 @@ void QmlBinding::update() value = con(value.toString()); } - if (d->property.propertyType() == QVariant::Url && - (value.type() == QVariant::String || value.type() == QVariant::ByteArray) && !value.isNull()) - value.setValue(context()->resolvedUrl(QUrl(value.toString()))); - if (d->property.propertyType() == QVariant::Vector3D && value.type() == QVariant::String) { value = qVariantFromValue(QmlStringConverters::vector3DFromString(value.toString())); diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index fdba79e..affb93b 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -874,6 +874,31 @@ void QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value) } break; + case QVariant::Url: + { + QUrl u; + if (vt == QVariant::ByteArray) { + u = QUrl(QLatin1String(value.toByteArray())); + found = true; + } else if (QVariant::String) { + u = QUrl(value.toString()); + found = true; + } + + if (context && u.isRelative()) + u = context->baseUrl().resolved(u); + + if (found) { + void *a[1]; + a[0] = &u; + QMetaObject::metacall(object, + QMetaObject::WriteProperty, + coreIdx, a); + } + + } + break; + default: { -- cgit v0.12