aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarative.h
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2011-08-03 11:04:01 +1000
committerQt by Nokia <qt-info@nokia.com>2011-08-30 07:15:51 +0200
commitbe244df6cdce029eeb04d3e919ccf5c4983bd3e4 (patch)
tree2d6d839d5e398f996c481411b94fb5e4131f944c /src/declarative/qml/qdeclarative.h
parent6cec35c85acdf458d14126784b7739c5419314eb (diff)
Implement script module api property get and set
This commit adds code for property get and set for script module APIs, and also splits up the module API unit tests into QObject and Script (QJSValue) parts. Related to commit: 3ee8a19f5b7142b96e2df649ea0dac444b5622a2 Task-number: QMLNG-33 Task-number: QTBUG-17318 Change-Id: I4aaf5d1cc1d4774dd0f0999f0985439e4d76f0ca Reviewed-on: http://codereview.qt.nokia.com/1472 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'src/declarative/qml/qdeclarative.h')
-rw-r--r--src/declarative/qml/qdeclarative.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h
index 311ecd31ca..a0eb98d366 100644
--- a/src/declarative/qml/qdeclarative.h
+++ b/src/declarative/qml/qdeclarative.h
@@ -420,33 +420,35 @@ Q_DECLARATIVE_EXPORT void qmlRegisterBaseTypes(const char *uri, int versionMajor
Installing a module API into a uri allows developers to provide arbitrary functionality
(methods and properties) in a namespace that doesn't necessarily contain elements.
- A module API may be either a QObject or a QScriptValue. Only one module API provider
+ A module API may be either a QObject or a QJSValue. Only one module API provider
may be registered into any given namespace (combination of \a uri, \a majorVersion and \a minorVersion).
- This function should be used to register a module API provider function which returns a QScriptValue as a module API.
+ This function should be used to register a module API provider function which returns a QJSValue as a module API.
+
+ \e NOTE: QJSValue module API properties will \e not trigger binding re-evaluation if changed.
Usage:
\code
// first, define the module API provider function (callback).
- static QScriptValue *example_qscriptvalue_module_api_provider(QDeclarativeEngine *engine, QScriptEngine *scriptEngine)
+ static QJSValue *example_qjsvalue_module_api_provider(QDeclarativeEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
static int seedValue = 5;
- QScriptValue example = scriptEngine->newObject();
+ QJSValue example = scriptEngine->newObject();
example.setProperty("someProperty", seedValue++);
return example;
}
// second, register the module API provider with QML by calling this function in an initialization function.
...
- qmlRegisterModuleApi("Qt.example.qscriptvalueApi", 1, 0, example_qscriptvalue_module_api_provider);
+ qmlRegisterModuleApi("Qt.example.qjsvalueApi", 1, 0, example_qjsvalue_module_api_provider);
...
\endcode
In order to use the registered module API in QML, you must import the module API.
\qml
import QtQuick 2.0
- import Qt.example.qscriptvalueApi 1.0 as ExampleApi
+ import Qt.example.qjsvalueApi 1.0 as ExampleApi
Item {
id: root
property int someValue: ExampleApi.someProperty
@@ -474,7 +476,7 @@ inline int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMi
Installing a module API into a uri allows developers to provide arbitrary functionality
(methods and properties) in a namespace that doesn't necessarily contain elements.
- A module API may be either a QObject or a QScriptValue. Only one module API provider
+ A module API may be either a QObject or a QJSValue. Only one module API provider
may be registered into any given namespace (combination of \a uri, \a majorVersion and \a minorVersion).
This function should be used to register a module API provider function which returns a QObject as a module API.
@@ -507,7 +509,7 @@ inline int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMi
};
// second, define the module API provider function (callback).
- static QObject *example_qobject_module_api_provider(QDeclarativeEngine *engine, QScriptEngine *scriptEngine)
+ static QObject *example_qobject_module_api_provider(QDeclarativeEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)