summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/parser/javascript.g5
-rw-r--r--src/declarative/qml/parser/javascriptparser.cpp5
-rw-r--r--src/declarative/qml/qmlcomponent.cpp29
-rw-r--r--src/declarative/qml/qmlcontext.cpp31
-rw-r--r--src/declarative/qml/qmlcontext.h2
-rw-r--r--src/declarative/qml/qmlcontext_p.h3
-rw-r--r--src/declarative/qml/qmlcustomparser.cpp44
-rw-r--r--src/declarative/qml/qmldom.h1
-rw-r--r--src/declarative/qml/qmlengine.cpp15
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp40
-rw-r--r--src/declarative/qml/qmlpropertyvaluesource.cpp7
11 files changed, 131 insertions, 51 deletions
diff --git a/src/declarative/qml/parser/javascript.g b/src/declarative/qml/parser/javascript.g
index 5482392..ec81a7a 100644
--- a/src/declarative/qml/parser/javascript.g
+++ b/src/declarative/qml/parser/javascript.g
@@ -2690,12 +2690,15 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
tk.dval = yylval;
tk.loc = yylloc;
+ yylloc = yyprevlloc;
+ yylloc.offset += yylloc.length;
+ yylloc.startColumn += yylloc.length;
yylloc.length = 0;
const QString msg = QString::fromUtf8("Missing `;'");
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning,
- yyprevlloc.startLine, yyprevlloc.startColumn, msg));
+ yylloc.startLine, yylloc.startColumn, msg));
first_token = &token_buffer[0];
last_token = &token_buffer[1];
diff --git a/src/declarative/qml/parser/javascriptparser.cpp b/src/declarative/qml/parser/javascriptparser.cpp
index 185a824..897f0ce 100644
--- a/src/declarative/qml/parser/javascriptparser.cpp
+++ b/src/declarative/qml/parser/javascriptparser.cpp
@@ -1547,12 +1547,15 @@ case 312: {
tk.dval = yylval;
tk.loc = yylloc;
+ yylloc = yyprevlloc;
+ yylloc.offset += yylloc.length;
+ yylloc.startColumn += yylloc.length;
yylloc.length = 0;
const QString msg = QString::fromUtf8("Missing `;'");
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning,
- yyprevlloc.startLine, yyprevlloc.startColumn, msg));
+ yylloc.startLine, yylloc.startColumn, msg));
first_token = &token_buffer[0];
last_token = &token_buffer[1];
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index 72d4e08..f0d23ee 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -173,6 +173,9 @@ QmlComponent::~QmlComponent()
d->cc->release();
}
+/*!
+ Returns the component's current \l{QmlComponent::Status} {status}.
+ */
QmlComponent::Status QmlComponent::status() const
{
Q_D(const QmlComponent);
@@ -235,7 +238,8 @@ bool QmlComponent::isLoading() const
*/
/*!
- Create a QmlComponent with no data. Set setData().
+ Create a QmlComponent with no data and give it the specified
+ \a engine and \a parent. Set the data with setData().
*/
QmlComponent::QmlComponent(QmlEngine *engine, QObject *parent)
: QObject(*(new QmlComponentPrivate), parent)
@@ -245,7 +249,10 @@ QmlComponent::QmlComponent(QmlEngine *engine, QObject *parent)
}
/*!
- Create a QmlComponent from the given \a url.
+ Create a QmlComponent from the given \a url and give it the
+ specified \a parent and \a engine.
+
+ \sa loadUrl()
*/
QmlComponent::QmlComponent(QmlEngine *engine, const QUrl &url, QObject *parent)
: QObject(*(new QmlComponentPrivate), parent)
@@ -256,9 +263,12 @@ QmlComponent::QmlComponent(QmlEngine *engine, const QUrl &url, QObject *parent)
}
/*!
- Create a QmlComponent from the given QML \a data. If provided, \a url
- is used to set the component name, and to provide a base path for items
- resolved by this component.
+ Create a QmlComponent from the given QML \a data and give it the
+ specified \a parent. If \a url is provided, it is used to set
+ the component name, and to provide a base path for items resolved
+ by this component.
+
+ \sa setData()
*/
QmlComponent::QmlComponent(QmlEngine *engine, const QByteArray &data, const QUrl &url, QObject *parent)
: QObject(*(new QmlComponentPrivate), parent)
@@ -283,9 +293,9 @@ QmlComponent::QmlComponent(QmlEngine *engine, QmlCompiledComponent *cc, int star
}
/*!
- Sets the QmlComponent to use the given QML \a data. If provided,
- \a url is used to set the component name, and to provide a base path
- for items resolved by this component.
+ Sets the QmlComponent to use the given QML \a data. If \a url
+ is provided, it is used to set the component name and to provide
+ a base path for items resolved by this component.
*/
void QmlComponent::setData(const QByteArray &data, const QUrl &url)
{
@@ -451,8 +461,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..68453c3 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,20 @@ QUrl QmlContext::resolvedUri(const QUrl &src)
}
}
+/*!
+ Explicitly sets the url both resolveUri() and resolveUrl() will
+ use for relative references to \a baseUrl.
+
+ 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();
diff --git a/src/declarative/qml/qmlcustomparser.cpp b/src/declarative/qml/qmlcustomparser.cpp
index 544c469..06035b0 100644
--- a/src/declarative/qml/qmlcustomparser.cpp
+++ b/src/declarative/qml/qmlcustomparser.cpp
@@ -52,11 +52,11 @@ using namespace QmlParser;
\brief The QmlCustomParser class allows you to add new arbitrary types to QML.
\internal
- By subclassing QmlCustomParser, you can add an XML parser for building a
- particular type.
+ By subclassing QmlCustomParser, you can add an XML parser for
+ building a particular type.
- The subclass must implement compile() and create(), and define itself in
- the meta type system with one of the macros:
+ The subclass must implement compile() and create(), and define
+ itself in the meta type system with one of the macros:
\code
QML_DEFINE_CUSTOM_PARSER(Name, parserClass)
@@ -67,33 +67,39 @@ using namespace QmlParser;
\endcode
*/
-/*!
+/*
\fn QByteArray QmlCustomParser::compile(QXmlStreamReader& reader, bool *ok)
- Upon entry to this function, \a reader is positioned on a QXmlStreamReader::StartElement
- with the name specified when the class was defined with the QML_DEFINE_CUSTOM_PARSER macro.
+ Upon entry to this function, \a reader is positioned on a
+ QXmlStreamReader::StartElement with the name specified when the
+ class was defined with the QML_DEFINE_CUSTOM_PARSER macro.
- The custom parser must consume tokens from \a reader until the EndElement matching the
- initial start element is reached, or until error.
+ The custom parser must consume tokens from \a reader until the
+ EndElement matching the initial start element is reached, or until
+ error.
On return, \c *ok indicates success.
- The returned QByteArray contains data meaningful only to the custom parser; the
- type engine will pass this same data to create() when making an instance of the data.
+ The returned QByteArray contains data meaningful only to the
+ custom parser; the type engine will pass this same data to
+ create() when making an instance of the data.
- The QByteArray may be cached between executions of the system, so it must contain
- correctly-serialized data (not, for example, pointers to stack objects).
+ The QByteArray may be cached between executions of the system, so
+ it must contain correctly-serialized data (not, for example,
+ pointers to stack objects).
*/
-/*!
+/*
\fn QVariant QmlCustomParser::create(const QByteArray &data)
- This function returns a QVariant containing the value represented by \a data, which
- is a block of data previously returned by a call to compile().
+ This function returns a QVariant containing the value represented
+ by \a data, which is a block of data previously returned by a call
+ to compile().
- If the compile is for a type, the variant should be a pointer to the
- correctly-named QObject subclass (i.e. the one defined by QML_DEFINE_TYPE for
- the same-named type as this custom parser is defined for).
+ If the compile is for a type, the variant should be a pointer to
+ the correctly-named QObject subclass (i.e. the one defined by
+ QML_DEFINE_TYPE for the same-named type as this custom parser is
+ defined for).
*/
QmlCustomParserNode
diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h
index 74ed27c..daca888 100644
--- a/src/declarative/qml/qmldom.h
+++ b/src/declarative/qml/qmldom.h
@@ -73,7 +73,6 @@ public:
int version() const;
QList<QmlError> errors() const;
- QString loadError() const;
bool load(QmlEngine *, const QByteArray &);
QByteArray save() const;
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index f8b7ad6..bcea325 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -408,6 +408,9 @@ QmlEngine::~QmlEngine()
{
}
+/*!
+ Clears the engine's internal component cache.
+ */
void QmlEngine::clearComponentCache()
{
Q_D(QmlEngine);
@@ -582,8 +585,8 @@ void QmlEngine::setNetworkAccessManager(QNetworkAccessManager *network)
}
/*!
- Returns the common QNetworkAccessManager used by all QML elements instantiated by
- this engine.
+ Returns the common QNetworkAccessManager used by all QML elements
+ instantiated by this engine.
The default implements no caching, cookiejar, etc., just a default
QNetworkAccessManager.
@@ -596,6 +599,9 @@ QNetworkAccessManager *QmlEngine::networkAccessManager() const
return d->networkAccessManager;
}
+/*!
+ Returns the QmlContext for the \a object.
+ */
QmlContext *QmlEngine::contextForObject(const QObject *object)
{
QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
@@ -606,6 +612,11 @@ QmlContext *QmlEngine::contextForObject(const QObject *object)
return data?data->context:0;
}
+/*!
+ Sets the QmlContext for the \a object to \a context.
+ If the \a object already has a context, a warning is
+ output, but the context is not changed.
+ */
void QmlEngine::setContextForObject(QObject *object, QmlContext *context)
{
QObjectPrivate *priv = QObjectPrivate::get(object);
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index 1a511eb..14a45dc 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -261,6 +261,33 @@ QmlMetaProperty::QmlMetaProperty(const QmlMetaProperty &other)
}
/*!
+ \enum QmlMetaProperty::PropertyCategory
+
+ This enum specifies a category of QML property.
+
+ \value Unknown
+ \value InvalidProperty
+ \value Bindable
+ \value List
+ \value QmlList
+ \value Object
+ \value Normal
+ */
+
+/*!
+ \enum QmlMetaProperty::Type
+
+ This enum specifies a type of QML property.
+
+ \value Invalid
+ \value Property
+ \value SignalProperty
+ \value Signal
+ \value Default
+ \value Attached
+*/
+
+/*!
Returns the property category.
*/
QmlMetaProperty::PropertyCategory QmlMetaProperty::propertyCategory() const
@@ -472,13 +499,17 @@ QStringList QmlMetaProperty::properties(QObject *obj)
}
/*!
- Return the name of this property.
+ Return the name of this QML property.
*/
QString QmlMetaProperty::name() const
{
return d->name;
}
+/*!
+ Returns the \l{QMetaProperty} {Qt property} associated with
+ this QML property.
+ */
const QMetaProperty &QmlMetaProperty::property() const
{
return d->prop;
@@ -1037,9 +1068,10 @@ quint32 QmlMetaProperty::save() const
}
/*!
- Restore a QmlMetaProperty from a previously saved id. \a obj must be the
- same object as used in the previous call to QmlMetaProperty::save(). Only
- the bottom 24-bits are used, the high bits can be set to any value.
+ Restore a QmlMetaProperty from a previously saved \a id.
+ \a obj must be the same object as used in the previous call
+ to QmlMetaProperty::save(). Only the bottom 24-bits are
+ used, the high bits can be set to any value.
*/
void QmlMetaProperty::restore(quint32 id, QObject *obj)
{
diff --git a/src/declarative/qml/qmlpropertyvaluesource.cpp b/src/declarative/qml/qmlpropertyvaluesource.cpp
index 44e1952..4770929 100644
--- a/src/declarative/qml/qmlpropertyvaluesource.cpp
+++ b/src/declarative/qml/qmlpropertyvaluesource.cpp
@@ -59,14 +59,17 @@ QmlPropertyValueSource::QmlPropertyValueSource(QObject *parent)
{
}
+/*!
+ \internal
+ */
QmlPropertyValueSource::QmlPropertyValueSource(QObjectPrivate &dd, QObject *parent)
: QObject(dd, parent)
{
}
/*!
- Set the target \a property for the value source. This method will be called
- by the QML engine when assigning a value source.
+ Set the target \a property for the value source. This method will
+ be called by the QML engine when assigning a value source.
The default implementation does nothing.
*/