summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2009-04-29 13:05:56 (GMT)
committerKai Koehne <kai.koehne@nokia.com>2009-05-05 09:51:11 (GMT)
commit4416bb70d751ff31818823f79d3d7ed3a3d94929 (patch)
treee4439a2afca26a443ee40136502bc7265cc23046 /src/declarative
parenta189a500173ed038e777902ac0a77f837a330c26 (diff)
downloadQt-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')
-rw-r--r--src/declarative/qml/qmlcomponent.cpp3
-rw-r--r--src/declarative/qml/qmlcontext.cpp29
-rw-r--r--src/declarative/qml/qmlcontext.h2
-rw-r--r--src/declarative/qml/qmlcontext_p.h3
4 files changed, 24 insertions, 13 deletions
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index 72d4e08..0a56636 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -451,8 +451,7 @@ QObject *QmlComponent::beginCreate(QmlContext *context)
QmlContext *ctxt =
new QmlContext(context, 0);
- static_cast<QmlContextPrivate*>(ctxt->d_ptr)->component = d->cc;
- static_cast<QmlContextPrivate*>(ctxt->d_ptr)->component->addref();
+ static_cast<QmlContextPrivate*>(ctxt->d_ptr)->url = d->cc->url;
ctxt->activate();
QmlVME vme;
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);
diff --git a/src/declarative/qml/qmlcontext.h b/src/declarative/qml/qmlcontext.h
index 9e3b6d8..39d565a 100644
--- a/src/declarative/qml/qmlcontext.h
+++ b/src/declarative/qml/qmlcontext.h
@@ -80,6 +80,8 @@ public:
QUrl resolvedUri(const QUrl &);
QUrl resolvedUrl(const QUrl &);
+ void setBaseUrl(const QUrl &);
+
private Q_SLOTS:
void objectDestroyed(QObject *);
diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h
index 3772885..40848fb 100644
--- a/src/declarative/qml/qmlcontext_p.h
+++ b/src/declarative/qml/qmlcontext_p.h
@@ -69,7 +69,8 @@ public:
QScriptValueList scopeChain;
- QmlCompiledComponent *component;
+ QUrl url;
+
void init();
void dump();