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/util | |
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/util')
-rw-r--r-- | src/declarative/util/qfxview.cpp | 6 | ||||
-rw-r--r-- | src/declarative/util/qmlscript.cpp | 17 | ||||
-rw-r--r-- | src/declarative/util/qmlscript.h | 6 |
3 files changed, 11 insertions, 18 deletions
diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp index 0d5b796..d8d9ba1 100644 --- a/src/declarative/util/qfxview.cpp +++ b/src/declarative/util/qfxview.cpp @@ -84,11 +84,6 @@ static QVariant stringToKeySequence(const QString &str) return QVariant::fromValue(QKeySequence(str)); } -static QVariant stringToUrl(const QString &str) -{ - return QVariant(QUrl(str)); -} - class QFxViewPrivate { public: @@ -166,7 +161,6 @@ void QFxViewPrivate::init() QmlMetaType::registerCustomStringConverter(QVariant::Pixmap, &stringToPixmap); QmlMetaType::registerCustomStringConverter(QVariant::Icon, &stringToIcon); QmlMetaType::registerCustomStringConverter(QVariant::KeySequence, &stringToKeySequence); - QmlMetaType::registerCustomStringConverter(QVariant::Url, &stringToUrl); #ifdef Q_ENABLE_PERFORMANCE_LOG QFxPerfTimer<QFxPerf::FontDatabase> perf; diff --git a/src/declarative/util/qmlscript.cpp b/src/declarative/util/qmlscript.cpp index 45370e2..e422f37 100644 --- a/src/declarative/util/qmlscript.cpp +++ b/src/declarative/util/qmlscript.cpp @@ -69,7 +69,6 @@ public: void addScriptToEngine(const QString &, const QString &fileName=QString()); QString script; - QString source; QNetworkReply *reply; QUrl url; }; @@ -138,26 +137,26 @@ void QmlScript::setScript(const QString &script) \property QmlScript::source \brief the path to a script file. */ -QString QmlScript::source() const +QUrl QmlScript::source() const { Q_D(const QmlScript); - return d->source; + return d->url; } -void QmlScript::setSource(const QString &source) +void QmlScript::setSource(const QUrl &source) { Q_D(QmlScript); - if (d->source == source) + if (d->url == source) return; - d->source = source; - d->url = qmlContext(this)->resolvedUrl(source); + d->url = source; + Q_ASSERT(!source.isRelative()); #ifndef QT_NO_LOCALFILE_OPTIMIZED_QML if (d->url.scheme() == QLatin1String("file")) { QFile file(d->url.toLocalFile()); file.open(QIODevice::ReadOnly); QByteArray ba = file.readAll(); - d->addScriptToEngine(QString::fromUtf8(ba), d->source); + d->addScriptToEngine(QString::fromUtf8(ba), d->url); } else #endif { @@ -174,7 +173,7 @@ void QmlScript::replyFinished() Q_D(QmlScript); if (!d->reply->error()) { QByteArray ba = d->reply->readAll(); - d->addScriptToEngine(QString::fromUtf8(ba), d->source); + d->addScriptToEngine(QString::fromUtf8(ba), d->url); } d->reply->deleteLater(); d->reply = 0; diff --git a/src/declarative/util/qmlscript.h b/src/declarative/util/qmlscript.h index dc090bc..09ebc2c 100644 --- a/src/declarative/util/qmlscript.h +++ b/src/declarative/util/qmlscript.h @@ -58,7 +58,7 @@ class Q_DECLARATIVE_EXPORT QmlScript : public QObject Q_DECLARE_PRIVATE(QmlScript) Q_PROPERTY(QString script READ script WRITE setScript) - Q_PROPERTY(QString source READ source WRITE setSource) + Q_PROPERTY(QUrl source READ source WRITE setSource) Q_CLASSINFO("DefaultProperty", "script") public: @@ -67,8 +67,8 @@ public: QString script() const; void setScript(const QString &); - QString source() const; - void setSource(const QString &); + QUrl source() const; + void setSource(const QUrl &); private Q_SLOTS: void replyFinished(); |