diff options
author | Antti Piira <apiira@blackberry.com> | 2013-08-22 12:08:37 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-21 01:20:55 +0200 |
commit | 200a869441562d62e7fc0867599097e0599f0411 (patch) | |
tree | 982dc3c5a9c22bdea24a21054dd2b434fcea1147 /tests/auto/qml/qqmllanguage/data/singletonTest13.error.txt | |
parent | b365471f0abc79f08bf0d852aea3be0a601c6901 (diff) |
Add Singleton support for QML
This introduces Singleton support for QML (Composite Singleton). For
now, the Singleton support is only availabe for QML types in modules
or (remote and local) directories with qmldir file. However, in the
future this support may be expanded to arbitrary QML file imports
without by leaving out the qmldir requirement.
You define a QML type as a Singleton with the following two steps:
1. By adding a pragma Singleton to a type's QML file:
pragma Singleton
The pragma and import statements can be mixed and their order does
not matter. Singleton is the only supported pragma for now. Others
will generate errors.
2. By specifying a qmldir file for the directory of your imported
type and prepending the type with "singleton" keyword as follows:
singleton TestTypeSingleton TestTypeSingleton.qml
Alternatively you may specify a qmldir file for a module and specify
your type as a singleton as follows:
singleton TestTypeSingleton 1.0 TestTypeSingleton.qml
Composite Singletons may be included in a module and may be used with
a local namespace qualifier when imported with:
"import xxx as NameSpace"
A singleton instance is created at first use and stored into the
QmlEngine (one instance per engine) and eventually released by the
engine's destructor.
CompositeSingletonType has a dual nature and will return true to both
isComposite() and isSingleton() calls. In most cases its enough to
check for just isComposite() or isSingleton(). However, there is a
isCompositeSingleton() available as well.
I used "qlalr --no-debug --no-lines --qt qqmljs.g" to generate the
qqmljsparser and qqmljsgrammar files from qqmljs.g.
Unit tests are included.
Change-Id: I91b303612c5e132143b325b9a8f982e9355bc90e
Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
Diffstat (limited to 'tests/auto/qml/qqmllanguage/data/singletonTest13.error.txt')
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/singletonTest13.error.txt | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/singletonTest13.error.txt b/tests/auto/qml/qqmllanguage/data/singletonTest13.error.txt new file mode 100644 index 0000000000..bc9cc61d57 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/singletonTest13.error.txt @@ -0,0 +1,2 @@ +-1:-1:Type ErrorSingletonType unavailable +-1:-1:qmldir defines type as singleton, but no pragma Singleton found in type ErrorSingletonType. |