diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2009-04-29 13:05:56 (GMT) |
---|---|---|
committer | Kai Koehne <kai.koehne@nokia.com> | 2009-05-05 09:51:11 (GMT) |
commit | 4416bb70d751ff31818823f79d3d7ed3a3d94929 (patch) | |
tree | e4439a2afca26a443ee40136502bc7265cc23046 /src/declarative/qml/qmlcontext.cpp | |
parent | a189a500173ed038e777902ac0a77f837a330c26 (diff) | |
download | Qt-4416bb70d751ff31818823f79d3d7ed3a3d94929.zip Qt-4416bb70d751ff31818823f79d3d7ed3a3d94929.tar.gz Qt-4416bb70d751ff31818823f79d3d7ed3a3d94929.tar.bz2 |
Removed dependency of QmlContext to QmlCompiledComponent
Store component url directly in context, instead of referencing the
associated QmlCompiledComponent. In addition, allow to explicitly set
the base url to a context. This is needed for Bauhaus.
Diffstat (limited to 'src/declarative/qml/qmlcontext.cpp')
-rw-r--r-- | src/declarative/qml/qmlcontext.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index 30857ad..6330eda 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -42,7 +42,6 @@ #include <qmlcontext.h> #include <private/qmlcontext_p.h> #include <private/qmlengine_p.h> -#include <private/qmlcompiledcomponent_p.h> #include <qmlengine.h> #include <qscriptengine.h> @@ -54,7 +53,7 @@ QT_BEGIN_NAMESPACE QmlContextPrivate::QmlContextPrivate() - : parent(0), engine(0), highPriorityCount(0), component(0) + : parent(0), engine(0), highPriorityCount(0) { } @@ -232,8 +231,6 @@ QmlContext::QmlContext(QmlContext *parentContext, QObject *parent) */ QmlContext::~QmlContext() { - Q_D(QmlContext); - if (d->component) d->component->release(); } @@ -344,7 +341,7 @@ QmlContext *QmlContext::activeContext() simply returned. If there is no containing component, an empty URL is returned. - \sa QmlEngine::componentUrl() + \sa QmlEngine::componentUrl(), setBaseUrl */ QUrl QmlContext::resolvedUrl(const QUrl &src) { @@ -352,14 +349,14 @@ QUrl QmlContext::resolvedUrl(const QUrl &src) if (src.isRelative()) { if (ctxt) { while(ctxt) { - if (ctxt->d_func()->component) + if(ctxt->d_func()->url.isValid()) break; else ctxt = ctxt->parentContext(); } if (ctxt) - return ctxt->d_func()->component->url.resolved(src); + return ctxt->d_func()->url.resolved(src); } return QUrl(); } else { @@ -373,7 +370,7 @@ QUrl QmlContext::resolvedUrl(const QUrl &src) \l {QmlEngine::nameSpacePaths()} {namespace paths} of the context's engine, returning the resolved URL. - \sa QmlEngine::componentUrl() + \sa QmlEngine::componentUrl(), setBaseUrl */ QUrl QmlContext::resolvedUri(const QUrl &src) { @@ -381,14 +378,14 @@ QUrl QmlContext::resolvedUri(const QUrl &src) if (src.isRelative()) { if (ctxt) { while(ctxt) { - if (ctxt->d_func()->component) + if (ctxt->d_func()->url.isValid()) break; else ctxt = ctxt->parentContext(); } if (ctxt) - return ctxt->d_func()->engine->componentUrl(src, ctxt->d_func()->component->url); + return ctxt->d_func()->engine->componentUrl(src, ctxt->d_func()->url); } return QUrl(); } else { @@ -396,6 +393,18 @@ QUrl QmlContext::resolvedUri(const QUrl &src) } } +/*! + Explicitly sets the url both resolveUri() and resolveUrl() will use for relative references. + + Calling this function will override the url of the containing component used by default. + + \sa resolvedUrl, resolvedUri +*/ +void QmlContext::setBaseUrl(const QUrl &baseUrl) +{ + d_func()->url = baseUrl; +} + void QmlContext::objectDestroyed(QObject *object) { Q_D(QmlContext); |