summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/parser/qdeclarativejslexer.cpp10
-rw-r--r--src/declarative/qml/qdeclarative.h14
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp10
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp31
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp89
-rw-r--r--src/declarative/qml/qdeclarativeengine.h2
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp30
-rw-r--r--src/declarative/qml/qdeclarativeerror.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp1
-rw-r--r--src/declarative/qml/qdeclarativeexpression_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeextensionplugin.cpp77
-rw-r--r--src/declarative/qml/qdeclarativeimageprovider.cpp3
-rw-r--r--src/declarative/qml/qdeclarativeinstruction_p.h3
-rw-r--r--src/declarative/qml/qdeclarativelist.cpp2
-rw-r--r--src/declarative/qml/qdeclarativemetatype.cpp25
-rw-r--r--src/declarative/qml/qdeclarativemetatype_p.h8
-rw-r--r--src/declarative/qml/qdeclarativeprivate.h30
-rw-r--r--src/declarative/qml/qdeclarativerewrite.cpp2
-rw-r--r--src/declarative/qml/qdeclarativerewrite_p.h4
-rw-r--r--src/declarative/qml/qdeclarativescriptparser.cpp99
-rw-r--r--src/declarative/qml/qdeclarativestringconverters.cpp8
-rw-r--r--src/declarative/qml/qdeclarativestringconverters_p.h2
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp4
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp5
-rw-r--r--src/declarative/qml/qdeclarativexmlhttprequest.cpp7
-rw-r--r--src/declarative/qml/qdeclarativexmlhttprequest_p.h4
27 files changed, 291 insertions, 184 deletions
diff --git a/src/declarative/qml/parser/qdeclarativejslexer.cpp b/src/declarative/qml/parser/qdeclarativejslexer.cpp
index fcaaece..65a6af2 100644
--- a/src/declarative/qml/parser/qdeclarativejslexer.cpp
+++ b/src/declarative/qml/parser/qdeclarativejslexer.cpp
@@ -103,7 +103,7 @@ Lexer::Lexer(Engine *eng, bool tokenizeComments)
prohibitAutomaticSemicolon(false),
tokenizeComments(tokenizeComments)
{
- driver->setLexer(this);
+ if (driver) driver->setLexer(this);
// allocate space for read buffers
buffer8 = new char[size8];
buffer16 = new QChar[size16];
@@ -677,9 +677,9 @@ int Lexer::lex()
setDone(Other);
} else
state = Start;
- driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
+ if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
} else if (current == 0) {
- driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
+ if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
setDone(Eof);
}
@@ -689,14 +689,14 @@ int Lexer::lex()
setDone(Bad);
err = UnclosedComment;
errmsg = QCoreApplication::translate("QDeclarativeParser", "Unclosed comment at end of file");
- driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
+ if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
} else if (isLineTerminator()) {
shiftWindowsLineBreak();
yylineno++;
} else if (current == '*' && next1 == '/') {
state = Start;
shift(1);
- driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
+ if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
}
break;
diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h
index 53ff51c..c6b64ae 100644
--- a/src/declarative/qml/qdeclarative.h
+++ b/src/declarative/qml/qdeclarative.h
@@ -116,7 +116,7 @@ int qmlRegisterType()
0
};
- return QDeclarativePrivate::registerType(type);
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
}
int qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message);
@@ -151,7 +151,7 @@ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMin
0
};
- return QDeclarativePrivate::registerType(type);
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
}
template<typename T>
@@ -184,7 +184,7 @@ int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const c
0
};
- return QDeclarativePrivate::registerType(type);
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
}
template<typename T, typename E>
@@ -217,7 +217,7 @@ int qmlRegisterExtendedType()
0
};
- return QDeclarativePrivate::registerType(type);
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
}
template<typename T, typename E>
@@ -258,7 +258,7 @@ int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor,
0
};
- return QDeclarativePrivate::registerType(type);
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
}
template<typename T>
@@ -278,7 +278,7 @@ int qmlRegisterInterface(const char *typeName)
qobject_interface_iid<T *>()
};
- return QDeclarativePrivate::registerType(interface);
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::InterfaceRegistration, &interface);
}
template<typename T>
@@ -312,7 +312,7 @@ int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
parser
};
- return QDeclarativePrivate::registerType(type);
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
}
class QDeclarativeContext;
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 23307c9..ba757fc 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -240,7 +240,7 @@ bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop,
if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: color expected"));
}
break;
-#ifndef QT_NO_TEXTDATE
+#ifndef QT_NO_DATESTRING
case QVariant::Date:
{
bool ok;
@@ -262,7 +262,7 @@ bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop,
if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: datetime expected"));
}
break;
-#endif // QT_NO_TEXTDATE
+#endif // QT_NO_DATESTRING
case QVariant::Point:
case QVariant::PointF:
{
@@ -416,7 +416,7 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
instr.storeColor.value = c.rgba();
}
break;
-#ifndef QT_NO_TEXTDATE
+#ifndef QT_NO_DATESTRING
case QVariant::Date:
{
QDate d = QDeclarativeStringConverters::dateFromString(string);
@@ -450,7 +450,7 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
instr.storeDateTime.valueIndex = index;
}
break;
-#endif // QT_NO_TEXTDATE
+#endif // QT_NO_DATESTRING
case QVariant::Point:
case QVariant::PointF:
{
@@ -1070,6 +1070,7 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj)
store.storeSignal.value =
output->indexForString(v->value.asScript().trimmed());
store.storeSignal.context = ctxt.stack;
+ store.storeSignal.name = output->indexForByteArray(prop->name);
output->bytecode << store;
}
@@ -2765,6 +2766,7 @@ bool QDeclarativeCompiler::completeComponentBuild()
bool isSharable = sharableTest.isSharable(expression);
QDeclarativeRewrite::RewriteBinding rewriteBinding;
+ rewriteBinding.setName('$'+binding.property->name);
expression = rewriteBinding(expression);
quint32 length = expression.length();
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index 36c4b49..1d48b1a 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -115,24 +115,10 @@ class QByteArray;
a small component within a QML file, or for defining a component that logically
belongs with other QML components within a file.
- For example, here is a component that is used by multiple \l Loader objects:
+ For example, here is a component that is used by multiple \l Loader objects.
+ It contains a top level \l Rectangle item:
- \qml
- Item {
- Component {
- id: redSquare
-
- Rectangle {
- color: "red"
- width: 10
- height: 10
- }
- }
-
- Loader { sourceComponent: redSquare }
- Loader { sourceComponent: redSquare; x: 20 }
- }
- \endqml
+ \snippet doc/src/snippets/declarative/component.qml 0
Notice that while a \l Rectangle by itself would be automatically
rendered and displayed, this is not the case for the above rectangle
@@ -141,12 +127,16 @@ class QByteArray;
file, and is not loaded until requested (in this case, by the
two \l Loader objects).
+ A Component cannot contain anything other
+ than an \c id and a single top level item. While the \c id is optional,
+ the top level item is not; you cannot define an empty component.
+
The Component element is commonly used to provide graphical components
for views. For example, the ListView::delegate property requires a Component
to specify how each list item is to be displayed.
- Component objects can also be dynamically generated using
- \l{Qt::createComponent}{Qt.createComponent()}.
+ Component objects can also be dynamically created using
+ \l{QML:Qt::createComponent()}{Qt.createComponent()}.
*/
/*!
@@ -607,6 +597,9 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q
the \a parent value. Note that if the returned object is to be displayed, you
must provide a valid \a parent value or set the returned object's \l{Item::parent}{parent}
property, or else the object will not be visible.
+
+ Dynamically created instances can be deleted with the \c destroy() method.
+ See \l {Dynamic Object Management} for more information.
*/
/*!
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 97ef99c..e8cb36e 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -115,22 +115,55 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass QtObject QObject
\since 4.7
- \brief The QtObject element is the most basic element in QML
+ \brief The QtObject element is the most basic element in QML.
The QtObject element is a non-visual element which contains only the
- objectName property. It is useful for when you need an extremely
- lightweight element to place your own custom properties in.
+ objectName property.
+
+ It can be useful to create a QtObject if you need an extremely
+ lightweight element to enclose a set of custom properties:
+
+ \snippet doc/src/snippets/declarative/qtobject.qml 0
It can also be useful for C++ integration, as it is just a plain
QObject. See the QObject documentation for further details.
*/
/*!
- \qmlproperty string QtObject::objectName
- This property allows you to give a name to this specific object instance.
+ \qmlproperty string QML:QtObject::objectName
+ This property holds the QObject::objectName for this specific object instance.
+
+ This allows a C++ application to locate an item within a QML component
+ using the QObject::findChild() method. For example, the following C++
+ application locates the child \l Rectangle item and dynamically changes its
+ \c color value:
+
+ \qml
+ // MyRect.qml
+
+ import Qt 4.7
+
+ Item {
+ width: 200; height: 200
+
+ Rectangle {
+ anchors.fill: parent
+ color: "red"
+ objectName: "myRect"
+ }
+ }
+ \endqml
+
+ \code
+ // main.cpp
+
+ QDeclarativeView view;
+ view.setSource(QUrl::fromLocalFile("MyRect.qml"));
+ view.show();
- See \l{scripting.html#accessing-child-qobjects}{Accessing Child QObjects}
- in the scripting documentation for details how objectName can be used from
- scripts.
+ QDeclarativeItem *item = view.rootObject()->findChild<QDeclarativeItem*>("myRect");
+ if (item)
+ item->setProperty("color", QColor(Qt::yellow));
+ \endcode
*/
struct StaticQtMetaObject : public QObject
@@ -195,7 +228,7 @@ There are also string based constructors for these types. See \l{qdeclarativebas
\section1 Date/Time Formatters
-The Qt object contains several functions for formatting dates and times.
+The Qt object contains several functions for formatting QDateTime, QDate and QTime values.
\list
\o \l{QML:Qt::formatDateTime}{string Qt.formatDateTime(datetime date, variant format)}
@@ -237,8 +270,8 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
}
/*!
-\qmlmethod url Qt::resolvedUrl(url)
-Returns \c url resolved relative to the URL of the caller.
+ \qmlmethod url Qt::resolvedUrl(url)
+ Returns \c url resolved relative to the URL of the caller.
*/
QUrl QDeclarativeScriptEngine::resolvedUrl(QScriptContext *context, const QUrl& url)
{
@@ -268,7 +301,9 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr
+ QDir::separator() + QLatin1String("OfflineStorage");
#endif
+#ifndef QT_NO_XMLSTREAMREADER
qt_add_qmlxmlhttprequest(this);
+#endif
qt_add_qmlsqldatabase(this);
// XXX A Multimedia "Qt.Sound" class also needs to be made available,
// XXX but we don't want a dependency in that cirection.
@@ -296,7 +331,7 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr
qtObject.setProperty(QLatin1String("tint"), newFunction(QDeclarativeEnginePrivate::tint, 2));
}
-#ifndef QT_NO_TEXTDATE
+#ifndef QT_NO_DATESTRING
//date/time formatting
qtObject.setProperty(QLatin1String("formatDate"),newFunction(QDeclarativeEnginePrivate::formatDate, 2));
qtObject.setProperty(QLatin1String("formatTime"),newFunction(QDeclarativeEnginePrivate::formatTime, 2));
@@ -545,9 +580,9 @@ void QDeclarativeEngine::clearComponentCache()
component instances should be added to sub-contexts parented to the
root context.
*/
-QDeclarativeContext *QDeclarativeEngine::rootContext()
+QDeclarativeContext *QDeclarativeEngine::rootContext() const
{
- Q_D(QDeclarativeEngine);
+ Q_D(const QDeclarativeEngine);
return d->rootContext;
}
@@ -1071,27 +1106,23 @@ QString QDeclarativeEnginePrivate::urlToLocalFileOrQrc(const QUrl& url)
\qmlmethod object Qt::createComponent(url)
Returns a \l Component object created using the QML file at the specified \a url,
-or \c null if there was an error in creating the component.
+or \c null if an empty string was given.
+
+The returned component's \l Component::status property indicates whether the
+component was successfully created. If the status is \c Component.Error,
+see \l Component::errorString() for an error description.
Call \l {Component::createObject()}{Component.createObject()} on the returned
component to create an object instance of the component.
-Here is an example. Notice it checks whether the component \l{Component::status}{status} is
-\c Component.Ready before calling \l {Component::createObject()}{createObject()}
-in case the QML file is loaded over a network and thus is not ready immediately.
-
-\snippet doc/src/snippets/declarative/componentCreation.js 0
-\codeline
-\snippet doc/src/snippets/declarative/componentCreation.js 1
+For example:
-If you are certain the files will be local, you could simplify to:
+\snippet doc/src/snippets/declarative/createComponent-simple.qml 0
-\snippet doc/src/snippets/declarative/componentCreation.js 2
+See \l {Dynamic Object Management} for more information on using this function.
To create a QML object from an arbitrary string of QML (instead of a file),
use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}.
-
-\sa {Dynamic Object Management}
*/
QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QScriptEngine *engine)
@@ -1140,7 +1171,7 @@ Note that this function returns immediately, and therefore may not work if
the \a qml string loads new components (that is, external QML files that have not yet been loaded).
If this is the case, consider using \l{QML:Qt::createComponent()}{Qt.createComponent()} instead.
-\sa {Dynamic Object Management}
+See \l {Dynamic Object Management} for more information on using this function.
*/
QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine)
@@ -1265,7 +1296,7 @@ QScriptValue QDeclarativeEnginePrivate::vector3d(QScriptContext *ctxt, QScriptEn
\qmlmethod string Qt::formatDate(datetime date, variant format)
Returns the string representation of \c date, formatted according to \c format.
*/
-#ifndef QT_NO_TEXTDATE
+#ifndef QT_NO_DATESTRING
QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptEngine*engine)
{
int argCount = ctxt->argumentCount();
@@ -1406,7 +1437,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr
}
return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
}
-#endif // QT_NO_TEXTDATE
+#endif // QT_NO_DATESTRING
/*!
\qmlmethod color Qt::rgba(real red, real green, real blue, real alpha)
diff --git a/src/declarative/qml/qdeclarativeengine.h b/src/declarative/qml/qdeclarativeengine.h
index 01487f5..d971d80 100644
--- a/src/declarative/qml/qdeclarativeengine.h
+++ b/src/declarative/qml/qdeclarativeengine.h
@@ -74,7 +74,7 @@ public:
QDeclarativeEngine(QObject *p = 0);
virtual ~QDeclarativeEngine();
- QDeclarativeContext *rootContext();
+ QDeclarativeContext *rootContext() const;
void clearComponentCache();
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index a5c8c38..3b5dd5a 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -304,7 +304,7 @@ public:
static QScriptValue consoleLog(QScriptContext*, QScriptEngine*);
static QScriptValue quit(QScriptContext*, QScriptEngine*);
-#ifndef QT_NO_TEXTDATE
+#ifndef QT_NO_DATESTRING
static QScriptValue formatDate(QScriptContext*, QScriptEngine*);
static QScriptValue formatTime(QScriptContext*, QScriptEngine*);
static QScriptValue formatDateTime(QScriptContext*, QScriptEngine*);
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index 001da46..1837366 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -485,24 +485,22 @@ void QDeclarativeEngineDebugServer::setBinding(int objectId,
if (object && context) {
+ QDeclarativeProperty property(object, propertyName, context);
if (isLiteralValue) {
- QDeclarativeProperty literalProperty(object, propertyName, context);
- literalProperty.write(expression);
+ property.write(expression);
+ } else if (hasValidSignal(object, propertyName)) {
+ QDeclarativeExpression *declarativeExpression = new QDeclarativeExpression(context, object, expression.toString());
+ QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression);
+ } else if (property.isProperty()) {
+ QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context);
+ binding->setTarget(property);
+ binding->setNotifyOnValueChanged(true);
+ QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding);
+ if (oldBinding)
+ oldBinding->destroy();
+ binding->update();
} else {
- if (hasValidSignal(object, propertyName)) {
- QDeclarativeProperty property(object, propertyName);
- QDeclarativeExpression *declarativeExpression = new QDeclarativeExpression(context, object, expression.toString());
- QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression);
- } else {
- QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context);
- QDeclarativeProperty property(object, propertyName);
- binding->setTarget(property);
- binding->setNotifyOnValueChanged(true);
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding);
- if (oldBinding)
- oldBinding->destroy();
- binding->update();
- }
+ qWarning() << "QDeclarativeEngineDebugServer::setBinding: unable to set property" << propertyName << "on object" << object;
}
}
}
diff --git a/src/declarative/qml/qdeclarativeerror.cpp b/src/declarative/qml/qdeclarativeerror.cpp
index 8717f56..0ab5cd9 100644
--- a/src/declarative/qml/qdeclarativeerror.cpp
+++ b/src/declarative/qml/qdeclarativeerror.cpp
@@ -250,7 +250,9 @@ QDebug operator<<(QDebug debug, const QDeclarativeError &error)
if (f.open(QIODevice::ReadOnly)) {
QByteArray data = f.readAll();
QTextStream stream(data, QIODevice::ReadOnly);
+#ifndef QT_NO_TEXTCODEC
stream.setCodec("UTF-8");
+#endif
const QString code = stream.readAll();
const QStringList lines = code.split(QLatin1Char('\n'));
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
index 9935e38..585fb69 100644
--- a/src/declarative/qml/qdeclarativeexpression.cpp
+++ b/src/declarative/qml/qdeclarativeexpression.cpp
@@ -604,6 +604,7 @@ QScriptValue QDeclarativeExpressionPrivate::scriptValue(QObject *secondaryScope,
scriptContext->pushScope(ep->globalClass->staticGlobalObject());
QDeclarativeRewrite::RewriteBinding rewriteBinding;
+ rewriteBinding.setName(name);
bool ok = true;
const QString code = rewriteBinding(expression, &ok);
if (ok)
diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h
index b629e20..1700335 100644
--- a/src/declarative/qml/qdeclarativeexpression_p.h
+++ b/src/declarative/qml/qdeclarativeexpression_p.h
@@ -194,6 +194,7 @@ public:
QString url; // This is a QString for a reason. QUrls are slooooooow...
int line;
+ QByteArray name; //function name, hint for the debugger
};
QDeclarativeQtScriptExpression::DeleteWatcher::DeleteWatcher(QDeclarativeQtScriptExpression *data)
diff --git a/src/declarative/qml/qdeclarativeextensionplugin.cpp b/src/declarative/qml/qdeclarativeextensionplugin.cpp
index 0660599..9b5eb61 100644
--- a/src/declarative/qml/qdeclarativeextensionplugin.cpp
+++ b/src/declarative/qml/qdeclarativeextensionplugin.cpp
@@ -50,23 +50,76 @@ QT_BEGIN_NAMESPACE
\ingroup plugins
- QDeclarativeExtensionPlugin is a plugin interface that makes it
- possible to offer extensions that can be loaded dynamically into
- applications using the QDeclarativeEngine class.
-
- Writing a QML extension plugin is achieved by subclassing this
- base class, reimplementing the pure virtual registerTypes()
- function, and exporting the class using the Q_EXPORT_PLUGIN2()
- macro.
+ QDeclarativeExtensionPlugin is a plugin interface that makes it possible to
+ create QML extensions that can be loaded dynamically into QML applications.
+ These extensions allow custom QML types to be made available to the QML engine.
+
+ To write a QML extension plugin:
+
+ \list
+ \o Subclass QDeclarativeExtensionPlugin, implement registerTypes() method
+ to register types using qmlRegisterType(), and export the class using the Q_EXPORT_PLUGIN2() macro
+ \o Write an appropriate project file for the plugin
+ \o Create a \l{Writing a qmldir file}{qmldir file} to describe the plugin
+ \endlist
QML extension plugins can be used to provide either application-specific or
library-like plugins. Library plugins should limit themselves to registering types,
as any manipulation of the engine's root context may cause conflicts
or other issues in the library user's code.
- See \l {Tutorial: Writing QML extensions with C++} for details on creating
- QML extensions, including how to build a plugin with with QDeclarativeExtensionPlugin.
- For a simple overview, see the \l{declarative/cppextensions/plugins}{plugins} example.
+
+ \section1 An example
+
+ Suppose there is a new \c TimeModel C++ class that should be made available
+ as a new QML element. It provides the current time through \c hour and \c minute
+ properties, like this:
+
+ \snippet examples/declarative/cppextensions/plugins/plugin.cpp 0
+ \dots
+
+ To make this class available as a QML type, create a plugin that registers
+ this type with a specific \l {QML Modules}{module} using qmlRegisterType(). For this example the plugin
+ module will be named \c com.nokia.TimeExample (as defined in the project
+ file further below).
+
+ \snippet examples/declarative/cppextensions/plugins/plugin.cpp plugin
+ \codeline
+ \snippet examples/declarative/cppextensions/plugins/plugin.cpp export
+
+ This registers the \c TimeModel class with the 1.0 version of this
+ plugin library, as a QML type called \c Time. The Q_ASSERT statement
+ ensures the module is imported correctly by any QML components that use this plugin.
+
+ The project file defines the project as a plugin library and specifies
+ it should be built into the \c com/nokia/TimeExample directory:
+
+ \code
+ TEMPLATE = lib
+ CONFIG += qt plugin
+ QT += declarative
+
+ DESTDIR = com/nokia/TimeExample
+ TARGET = qmlqtimeexampleplugin
+ ...
+ \endcode
+
+ Finally, a \l{Writing a qmldir file}{qmldir file} is required in the \c com/nokia/TimeExample directory
+ that describes the plugin. This directory includes a \c Clock.qml file that
+ should be bundled with the plugin, so it needs to be specified in the \c qmldir
+ file:
+
+ \quotefile examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir
+
+ Once the project is built and installed, the new \c Time element can be
+ used by any QML component that imports the \c com.nokia.TimeExample module:
+
+ \snippet examples/declarative/cppextensions/plugins/plugins.qml 0
+
+ The full source code is available in the \l {declarative/cppextensions/plugins}{plugins example}.
+
+ The \l {Tutorial: Writing QML extensions with C++} also contains a chapter
+ on creating QML plugins.
\sa QDeclarativeEngine::importPlugin(), {How to Create Qt Plugins}
*/
@@ -95,7 +148,7 @@ QDeclarativeExtensionPlugin::QDeclarativeExtensionPlugin(QObject *parent)
}
/*!
- Destroys the plugin.
+ \internal
*/
QDeclarativeExtensionPlugin::~QDeclarativeExtensionPlugin()
{
diff --git a/src/declarative/qml/qdeclarativeimageprovider.cpp b/src/declarative/qml/qdeclarativeimageprovider.cpp
index a294c38..241df87 100644
--- a/src/declarative/qml/qdeclarativeimageprovider.cpp
+++ b/src/declarative/qml/qdeclarativeimageprovider.cpp
@@ -212,9 +212,6 @@ QImage QDeclarativeImageProvider::requestImage(const QString &id, QSize *size, c
In all cases, \a size must be set to the original size of the image. This
is used to set the \l {Item::}{width} and \l {Item::}{height} of image
elements that should be automatically sized to the loaded image.
-
- \note this method may be called by multiple threads, so ensure the
- implementation of this method is reentrant.
*/
QPixmap QDeclarativeImageProvider::requestPixmap(const QString &id, QSize *size, const QSize& requestedSize)
{
diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h
index d1a0a0a..f0b032c 100644
--- a/src/declarative/qml/qdeclarativeinstruction_p.h
+++ b/src/declarative/qml/qdeclarativeinstruction_p.h
@@ -292,7 +292,8 @@ public:
struct StoreSignalInstruction {
int signalIndex;
int value;
- int context;
+ short context;
+ int name;
};
struct AssignSignalObjectInstruction {
int signal;
diff --git a/src/declarative/qml/qdeclarativelist.cpp b/src/declarative/qml/qdeclarativelist.cpp
index 7c89672..9598d98 100644
--- a/src/declarative/qml/qdeclarativelist.cpp
+++ b/src/declarative/qml/qdeclarativelist.cpp
@@ -306,7 +306,7 @@ int QDeclarativeListReference::count() const
/*!
\class QDeclarativeListProperty
\since 4.7
-\brief The QDeclarativeListProperty class allows applications to explose list-like
+\brief The QDeclarativeListProperty class allows applications to expose list-like
properties to QML.
QML has many list properties, where more than one object value can be assigned.
diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp
index 153e2be..a5c878f 100644
--- a/src/declarative/qml/qdeclarativemetatype.cpp
+++ b/src/declarative/qml/qdeclarativemetatype.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
+#include <QtDeclarative/qdeclarativeprivate.h>
#include "private/qdeclarativemetatype_p.h"
#include "private/qdeclarativeproxymetaobject_p.h"
@@ -485,17 +486,17 @@ int QDeclarativeType::index() const
return d->m_index;
}
-int QDeclarativePrivate::registerAutoParentFunction(AutoParentFunction function)
+int registerAutoParentFunction(QDeclarativePrivate::RegisterAutoParent &autoparent)
{
QWriteLocker lock(metaTypeDataLock());
QDeclarativeMetaTypeData *data = metaTypeData();
- data->parentFunctions.append(function);
+ data->parentFunctions.append(autoparent.function);
return data->parentFunctions.count() - 1;
}
-int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterInterface &interface)
+int registerInterface(const QDeclarativePrivate::RegisterInterface &interface)
{
if (interface.version > 0)
qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
@@ -524,7 +525,7 @@ int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterInterfa
return index;
}
-int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &type)
+int registerType(const QDeclarativePrivate::RegisterType &type)
{
if (type.elementName) {
for (int ii = 0; type.elementName[ii]; ++ii) {
@@ -576,6 +577,22 @@ int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &t
}
/*
+This method is "over generalized" to allow us to (potentially) register more types of things in
+the future without adding exported symbols.
+*/
+int QDeclarativePrivate::qmlregister(RegistrationType type, void *data)
+{
+ if (type == TypeRegistration) {
+ return registerType(*reinterpret_cast<RegisterType *>(data));
+ } else if (type == InterfaceRegistration) {
+ return registerInterface(*reinterpret_cast<RegisterInterface *>(data));
+ } else if (type == AutoParentRegistration) {
+ return registerAutoParentFunction(*reinterpret_cast<RegisterAutoParent *>(data));
+ }
+ return -1;
+}
+
+/*
Have any types been registered for \a module with at least versionMajor.versionMinor, and types
for \a module with at most versionMajor.versionMinor.
diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h
index 4c98b6f..f410547 100644
--- a/src/declarative/qml/qdeclarativemetatype_p.h
+++ b/src/declarative/qml/qdeclarativemetatype_p.h
@@ -63,6 +63,8 @@ QT_BEGIN_NAMESPACE
class QDeclarativeType;
class QDeclarativeCustomParser;
+class QDeclarativeTypePrivate;
+
class Q_DECLARATIVE_EXPORT QDeclarativeMetaType
{
public:
@@ -103,7 +105,6 @@ public:
static QList<QDeclarativePrivate::AutoParentFunction> parentFunctions();
};
-class QDeclarativeTypePrivate;
class Q_DECLARATIVE_EXPORT QDeclarativeType
{
public:
@@ -144,11 +145,12 @@ public:
int propertyValueInterceptorCast() const;
int index() const;
+
private:
friend class QDeclarativeTypePrivate;
friend struct QDeclarativeMetaTypeData;
- friend int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterInterface &);
- friend int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &);
+ friend int registerType(const QDeclarativePrivate::RegisterType &);
+ friend int registerInterface(const QDeclarativePrivate::RegisterInterface &);
QDeclarativeType(int, const QDeclarativePrivate::RegisterInterface &);
QDeclarativeType(int, const QDeclarativePrivate::RegisterType &);
~QDeclarativeType();
diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h
index cd859fe..b2d7451 100644
--- a/src/declarative/qml/qdeclarativeprivate.h
+++ b/src/declarative/qml/qdeclarativeprivate.h
@@ -42,6 +42,17 @@
#ifndef QDECLARATIVEPRIVATE_H
#define QDECLARATIVEPRIVATE_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtCore/qglobal.h>
#include <QtCore/qvariant.h>
#ifndef Q_OS_WIN
@@ -177,6 +188,9 @@ namespace QDeclarativePrivate
return AttachedPropertySelector<T, has_attachedPropertiesMethod<T, has_attachedPropertiesMember<T>::value>::value>::metaObject();
}
+ enum AutoParentResult { Parented, IncompatibleObject, IncompatibleParent };
+ typedef AutoParentResult (*AutoParentFunction)(QObject *object, QObject *parent);
+
struct RegisterType {
int version;
@@ -214,13 +228,19 @@ namespace QDeclarativePrivate
const char *iid;
};
- enum AutoParentResult { Parented, IncompatibleObject, IncompatibleParent };
- typedef AutoParentResult (*AutoParentFunction)(QObject *object, QObject *parent);
+ struct RegisterAutoParent {
+ int version;
- int Q_DECLARATIVE_EXPORT registerAutoParentFunction(AutoParentFunction);
- int Q_DECLARATIVE_EXPORT registerType(const RegisterType &);
- int Q_DECLARATIVE_EXPORT registerType(const RegisterInterface &);
+ AutoParentFunction function;
+ };
+
+ enum RegistrationType {
+ TypeRegistration = 0,
+ InterfaceRegistration = 1,
+ AutoParentRegistration = 2
+ };
+ int Q_DECLARATIVE_EXPORT qmlregister(RegistrationType, void *);
}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativerewrite.cpp b/src/declarative/qml/qdeclarativerewrite.cpp
index 3d40e77..bc9a114 100644
--- a/src/declarative/qml/qdeclarativerewrite.cpp
+++ b/src/declarative/qml/qdeclarativerewrite.cpp
@@ -102,7 +102,7 @@ QString RewriteBinding::rewrite(QString code, unsigned position,
unsigned startOfStatement = node->firstSourceLocation().begin() - _position;
unsigned endOfStatement = node->lastSourceLocation().end() - _position;
- _writer->replace(startOfStatement, 0, QLatin1String("(function() { "));
+ _writer->replace(startOfStatement, 0, QLatin1String("(function ") + QString::fromUtf8(_name) + QLatin1String("() { "));
_writer->replace(endOfStatement, 0, QLatin1String(" })"));
if (rewriteDump()) {
diff --git a/src/declarative/qml/qdeclarativerewrite_p.h b/src/declarative/qml/qdeclarativerewrite_p.h
index 33b168c..6f3c46e 100644
--- a/src/declarative/qml/qdeclarativerewrite_p.h
+++ b/src/declarative/qml/qdeclarativerewrite_p.h
@@ -78,10 +78,14 @@ class RewriteBinding: protected AST::Visitor
{
unsigned _position;
TextWriter *_writer;
+ QByteArray _name;
public:
QString operator()(const QString &code, bool *ok = 0);
+ //name of the function: used for the debugger
+ void setName(const QByteArray &name) { _name = name; }
+
protected:
using AST::Visitor::visit;
diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp
index 219d759..f703cf5 100644
--- a/src/declarative/qml/qdeclarativescriptparser.cpp
+++ b/src/declarative/qml/qdeclarativescriptparser.cpp
@@ -831,7 +831,9 @@ bool QDeclarativeScriptParser::parse(const QByteArray &qmldata, const QUrl &url)
_scriptFile = fileName;
QTextStream stream(qmldata, QIODevice::ReadOnly);
+#ifndef QT_NO_TEXTCODEC
stream.setCodec("UTF-8");
+#endif
const QString code = stream.readAll();
data = new QDeclarativeScriptParserJsASTData(fileName);
@@ -896,6 +898,14 @@ QList<QDeclarativeError> QDeclarativeScriptParser::errors() const
return _errors;
}
+static void replaceWithSpace(QString &str, int idx, int n)
+{
+ QChar *data = str.data() + idx;
+ QChar space(' ');
+ for (int ii = 0; ii < n; ++ii)
+ *data++ = space;
+}
+
/*
Searches for ".pragma <value>" declarations within \a script. Currently supported pragmas
are:
@@ -905,83 +915,48 @@ QDeclarativeParser::Object::ScriptBlock::Pragmas QDeclarativeScriptParser::extra
{
QDeclarativeParser::Object::ScriptBlock::Pragmas rv = QDeclarativeParser::Object::ScriptBlock::None;
- const QChar forwardSlash(QLatin1Char('/'));
- const QChar star(QLatin1Char('*'));
- const QChar newline(QLatin1Char('\n'));
- const QChar dot(QLatin1Char('.'));
- const QChar semicolon(QLatin1Char(';'));
- const QChar space(QLatin1Char(' '));
- const QString pragma(QLatin1String(".pragma "));
-
- const QChar *pragmaData = pragma.constData();
-
- const QChar *data = script.constData();
- const int length = script.count();
- for (int ii = 0; ii < length; ++ii) {
- const QChar &c = data[ii];
-
- if (c.isSpace())
- continue;
-
- if (c == forwardSlash) {
- ++ii;
- if (ii >= length)
- return rv;
-
- const QChar &c = data[ii];
- if (c == forwardSlash) {
- // Find next newline
- while (ii < length && data[++ii] != newline) {};
- } else if (c == star) {
- // Find next star
- while (true) {
- while (ii < length && data[++ii] != star) {};
- if (ii + 1 >= length)
- return rv;
-
- if (data[ii + 1] == forwardSlash) {
- ++ii;
- break;
- }
- }
- } else {
- return rv;
- }
- } else if (c == dot) {
- // Could be a pragma!
- if (ii + pragma.length() >= length ||
- 0 != ::memcmp(data + ii, pragmaData, sizeof(QChar) * pragma.length()))
- return rv;
+ const QString pragma(QLatin1String("pragma"));
+ const QString library(QLatin1String("library"));
- int pragmaStatementIdx = ii;
+ QDeclarativeJS::Lexer l(0);
+ l.setCode(script, 0);
- ii += pragma.length();
+ int token = l.lex();
- while (ii < length && data[ii].isSpace()) { ++ii; }
+ while (true) {
+ if (token != QDeclarativeJSGrammar::T_DOT)
+ return rv;
- int startIdx = ii;
+ int startOffset = l.tokenOffset();
+ int startLine = l.currentLineNo();
- while (ii < length && data[ii].isLetter()) { ++ii; }
+ token = l.lex();
- int endIdx = ii;
+ if (token != QDeclarativeJSGrammar::T_IDENTIFIER ||
+ l.currentLineNo() != startLine ||
+ script.mid(l.tokenOffset(), l.tokenLength()) != pragma)
+ return rv;
- if (ii != length && data[ii] != forwardSlash && !data[ii].isSpace() && data[ii] != semicolon)
- return rv;
+ token = l.lex();
- QString p(data + startIdx, endIdx - startIdx);
+ if (token != QDeclarativeJSGrammar::T_IDENTIFIER ||
+ l.currentLineNo() != startLine)
+ return rv;
- if (p == QLatin1String("library"))
- rv |= QDeclarativeParser::Object::ScriptBlock::Shared;
- else
- return rv;
+ QString pragmaValue = script.mid(l.tokenOffset(), l.tokenLength());
+ int endOffset = l.tokenLength() + l.tokenOffset();
- for (int jj = pragmaStatementIdx; jj < endIdx; ++jj) script[jj] = space;
+ token = l.lex();
+ if (l.currentLineNo() == startLine)
+ return rv;
+ if (pragmaValue == QLatin1String("library")) {
+ rv |= QDeclarativeParser::Object::ScriptBlock::Shared;
+ replaceWithSpace(script, startOffset, endOffset - startOffset);
} else {
return rv;
}
}
-
return rv;
}
diff --git a/src/declarative/qml/qdeclarativestringconverters.cpp b/src/declarative/qml/qdeclarativestringconverters.cpp
index 8bd2cf1..7534a2c 100644
--- a/src/declarative/qml/qdeclarativestringconverters.cpp
+++ b/src/declarative/qml/qdeclarativestringconverters.cpp
@@ -106,14 +106,14 @@ QVariant QDeclarativeStringConverters::variantFromString(const QString &s, int p
return QVariant(uint(qRound(s.toDouble(ok))));
case QMetaType::QColor:
return QVariant::fromValue(colorFromString(s, ok));
-#ifndef QT_NO_TEXTDATE
+#ifndef QT_NO_DATESTRING
case QMetaType::QDate:
return QVariant::fromValue(dateFromString(s, ok));
case QMetaType::QTime:
return QVariant::fromValue(timeFromString(s, ok));
case QMetaType::QDateTime:
return QVariant::fromValue(dateTimeFromString(s, ok));
-#endif // QT_NO_TEXTDATE
+#endif // QT_NO_DATESTRING
case QMetaType::QPointF:
return QVariant::fromValue(pointFFromString(s, ok));
case QMetaType::QPoint:
@@ -152,7 +152,7 @@ QColor QDeclarativeStringConverters::colorFromString(const QString &s, bool *ok)
}
}
-#ifndef QT_NO_TEXTDATE
+#ifndef QT_NO_DATESTRING
QDate QDeclarativeStringConverters::dateFromString(const QString &s, bool *ok)
{
QDate d = QDate::fromString(s, Qt::ISODate);
@@ -173,7 +173,7 @@ QDateTime QDeclarativeStringConverters::dateTimeFromString(const QString &s, boo
if (ok) *ok = d.isValid();
return d;
}
-#endif // QT_NO_TEXTDATE
+#endif // QT_NO_DATESTRING
//expects input of "x,y"
QPointF QDeclarativeStringConverters::pointFFromString(const QString &s, bool *ok)
diff --git a/src/declarative/qml/qdeclarativestringconverters_p.h b/src/declarative/qml/qdeclarativestringconverters_p.h
index 842d1b3..e6b0abe 100644
--- a/src/declarative/qml/qdeclarativestringconverters_p.h
+++ b/src/declarative/qml/qdeclarativestringconverters_p.h
@@ -73,7 +73,7 @@ namespace QDeclarativeStringConverters
QVariant Q_DECLARATIVE_EXPORT variantFromString(const QString &, int preferredType, bool *ok = 0);
QColor Q_DECLARATIVE_EXPORT colorFromString(const QString &, bool *ok = 0);
-#ifndef QT_NO_TEXTDATE
+#ifndef QT_NO_DATESTRING
QDate Q_DECLARATIVE_EXPORT dateFromString(const QString &, bool *ok = 0);
QTime Q_DECLARATIVE_EXPORT timeFromString(const QString &, bool *ok = 0);
QDateTime Q_DECLARATIVE_EXPORT dateTimeFromString(const QString &, bool *ok = 0);
diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp
index c17ec95..98e9a58 100644
--- a/src/declarative/qml/qdeclarativevaluetype.cpp
+++ b/src/declarative/qml/qdeclarativevaluetype.cpp
@@ -74,7 +74,7 @@ int qmlRegisterValueTypeEnums(const char *qmlName)
0
};
- return QDeclarativePrivate::registerType(type);
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
}
QDeclarativeValueTypeFactory::QDeclarativeValueTypeFactory()
@@ -973,7 +973,7 @@ qreal QDeclarativeFontValueType::letterSpacing() const
void QDeclarativeFontValueType::setLetterSpacing(qreal size)
{
- font.setLetterSpacing(QFont::PercentageSpacing, size);
+ font.setLetterSpacing(QFont::AbsoluteSpacing, size);
}
qreal QDeclarativeFontValueType::wordSpacing() const
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index 3247f85..4e41c22 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -621,14 +621,15 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreSignal:
{
QObject *target = stack.top();
- QObject *context = stack.at(stack.count() - 1 - instr.assignBinding.context);
-
+ QObject *context = stack.at(stack.count() - 1 - instr.storeSignal.context);
+
QMetaMethod signal = target->metaObject()->method(instr.storeSignal.signalIndex);
QDeclarativeBoundSignal *bs = new QDeclarativeBoundSignal(target, signal, target);
QDeclarativeExpression *expr =
new QDeclarativeExpression(ctxt, context, primitives.at(instr.storeSignal.value));
expr->setSourceLocation(comp->name, instr.line);
+ static_cast<QDeclarativeExpressionPrivate *>(QObjectPrivate::get(expr))->name = datas.at(instr.storeSignal.name);
bs->setExpression(expr);
}
break;
diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
index acd1f51..ff1a0e9 100644
--- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp
+++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
@@ -58,6 +58,8 @@
#include <QtCore/qstack.h>
#include <QtCore/qdebug.h>
+#ifndef QT_NO_XMLSTREAMREADER
+
// From DOM-Level-3-Core spec
// http://www.w3.org/TR/DOM-Level-3-Core/core.html
#define INDEX_SIZE_ERR 1
@@ -1304,10 +1306,11 @@ QString QDeclarativeXMLHttpRequest::responseBody() const
{
QXmlStreamReader reader(m_responseEntityBody);
reader.readNext();
+#ifndef QT_NO_TEXTCODEC
QTextCodec *codec = QTextCodec::codecForName(reader.documentEncoding().toString().toUtf8());
if (codec)
return codec->toUnicode(m_responseEntityBody);
-
+#endif
return QString::fromUtf8(m_responseEntityBody);
}
@@ -1662,4 +1665,6 @@ void qt_add_qmlxmlhttprequest(QScriptEngine *engine)
QT_END_NAMESPACE
+#endif // QT_NO_XMLSTREAMREADER
+
#include <qdeclarativexmlhttprequest.moc>
diff --git a/src/declarative/qml/qdeclarativexmlhttprequest_p.h b/src/declarative/qml/qdeclarativexmlhttprequest_p.h
index 068cd0f..f340c1c 100644
--- a/src/declarative/qml/qdeclarativexmlhttprequest_p.h
+++ b/src/declarative/qml/qdeclarativexmlhttprequest_p.h
@@ -56,6 +56,8 @@
#include <QtCore/qglobal.h>
+#ifndef QT_NO_XMLSTREAMREADER
+
QT_BEGIN_NAMESPACE
class QScriptEngine;
@@ -63,5 +65,7 @@ void qt_add_qmlxmlhttprequest(QScriptEngine *engine);
QT_END_NAMESPACE
+#endif // QT_NO_XMLSTREAMREADER
+
#endif // QDECLARATIVEXMLHTTPREQUEST_P_H