From 800b1ad057d97f90555af3c94f08a935526373cf Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 22 Jun 2010 13:12:49 +1000 Subject: Doc --- src/declarative/qml/qdeclarativeinclude.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp index 388f252..c29005a 100644 --- a/src/declarative/qml/qdeclarativeinclude.cpp +++ b/src/declarative/qml/qdeclarativeinclude.cpp @@ -172,6 +172,29 @@ void QDeclarativeInclude::callback(QScriptEngine *engine, QScriptValue &callback } } +/*! +\qmlmethod object Qt::include(url, callback) + +Include another JavaScript file. This method can only be used from within JavaScript files, +and not regular QML files. + +Qt.include() returns an object that describes the status of the operation. The object has +a single property, \c {status} that is set to one of the following values: + +\table +\header \o Symbol \o Value \o Description +\row \o result.OK \o 0 \o The include completed successfully. +\row \o result.LOADING \o 1 \o Data is being loaded from the network. +\row \o result.NETWORK_ERROR \o 2 \o A network error occurred while fetching the url. +\row \o result.EXCEPTION \o 3 \o A JavaScript exception occurred while executing the included code. +An additional \c exception property will be set in this case. +\endtable + +The return object's properties will be updated as the operation progresses. + +If provided, \a callback is invoked when the operation completes. The callback is passed +the same object as is returned from the Qt.include() call. +*/ QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *engine) { if (ctxt->argumentCount() == 0) @@ -184,7 +207,7 @@ QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *e return ctxt->throwError(QLatin1String("Qt.include(): Can only be called from JavaScript files")); QString urlString = ctxt->argument(0).toString(); - QUrl url(ctxt->argument(0).toString()); + QUrl url(urlString); if (url.isRelative()) { url = QUrl(contextUrl).resolved(url); urlString = url.toString(); -- cgit v0.12